What is the return value type of count(*) in the ResultSet of a Prepared Statement with Spring JdbcTemplate?
String query = "select count(*) as ROW_COUNT from table1";
List<Map<String, Object>> list = executePreparedStatement(query);
Iterator<Map<String, Object>> iter = list.iterator();
if (iter.hasNext()) {
Map<String, Object> lom = iter.next();
return (((Long) lom.get("ROW_COUNT"))).intValue();
}
Does this depend on the JDBC driver / and or the database?
For example in DB2 the return value type was Integer, but in PostgreSQL it is Long.
Why is this different?
return (((Number) lom.get("ROW_COUNT"))).intValue();
? – StanislavL