我想寻找与枚举相匹配的东西:分裂:U6,U7,U8 ...... 它在我这样做时有效。
public ArrayList<Training> zoekTrainingen(Ploegen p) throws
ApplicationException {
ArrayList<Training> tr = new ArrayList<>();
Connection conn = ConnectionManager.getConnection(driver,
dburl, login, paswoord);
try (PreparedStatement stmt = conn.prepareStatement(
"select * from trainingen");) {
stmt.execute();
ResultSet r = stmt.getResultSet();
while (r.next()) {
---
}
} catch (SQLException sqlEx) {
throw new ApplicationException("");
}
finally {
return tr;
}
}
}
但是当我这样做时:
try (PreparedStatement stmt = conn.prepareStatement(
"select * from trainingen where Divsion = ?");) {
stmt.setString(1, p.getDivision());
我什么都没得到
答案 0 :(得分:0)
代码正在尝试使用String
设置Enum
参数。它应该获得Enum的String
值并传递给setString
方法。
try (PreparedStatement stmt = conn.prepareStatement(
"select * from trainingen where Divsion = ?");) {
stmt.setString(1, p.getDivision().toString());