Search code examples
javasqlspringibatis

How to use the SimpleJdbcTemplate queryForMap


Is there a way to get a Map<String,Integer> for instance? The call seems to return only a Map<String, Object> which I can't cast to Map<String,Integer>.


Solution

  • I usually use it like this:

    Map result = simpleJdbcTemplate.queryForMap(
     "SELECT COUNT(*) AS intRecords " +
     "FROM tblUsers",
     new Object[]);
    
    Integer users = result.get("intRecords");
    

    Does that help you?