The following Java code returns an empty result set but the SQL shows that there is data in the table:
@Override
public List<Category> list() {
List<Category> list = new ArrayList<>();
if (!connection.isPresent()) {
return list;
}
Connection con = connection.get();
try {
Statement stmnt = con.createStatement();
ResultSet rs = stmnt.executeQuery(LIST_SQL);
while (rs.next()) {
System.out.println("Got a record"); // DEBUG
int id = rs.getInt(1);
String description = rs.getString(2);
list.add(new Category(id, description));
}
} catch (SQLException e) {
LOG.error("Error retrieving Category list", e);
return list;
}
return list;
}
LIST_SQL
is:
SELECT id, description FROM category
If I copy this query into sqlite3
and execute it, several rows are returned. connection
works with other queries (but they are prepared statements and not an executeQuery
). There is no error. "Got a record" is never printed.
Any ideas about what could be going wrong?
Aucun commentaire:
Enregistrer un commentaire