sqlBuffer.append("SELECT * FROM categories");
ResultSet resultSet = null;
try {
resultSet = excecuteScrollableQuery(sqlBuffer.toString());
while (resultSet.next()) {
Category category = new Category();
category.setId(new Integer(resultSet.getInt("ID")));
category.setName(resultSet.getString("NAME"));
categories.add(category);
sqlBuffer = new StringBuffer();
sqlBuffer.append("SELECT count(*) as nbItems FROM items WHERE CATEGORY=");
sqlBuffer.append(category.getId());
ResultSet countResultSet = excecuteScrollableQuery(sqlBuffer.toString());
if(countResultSet.next()){
int count = countResultSet.getInt(1);
category.setNbItems(count);
}
closeConnection(countResultSet);
}
} catch (SQLException e) {
throw new RuntimeException(e);