f-angi
5/5/2016 - 10:34 AM

Retrieves a map using JdbcTemplate

Retrieves a map using JdbcTemplate

jdbcTemplate.query(sqlString, new ResultSetExtractor<Map<String, String>>() {

  @Override
  public Map<String, String> extractData(ResultSet rs) {

      LinkedHashMap<String, String> mapRet = new LinkedHashMap<String, String>();
      try {
          while (rs.next()) {
              mapRet.put(rs.getString("sigla"), rs.getString("descr"));
          }
      }
      catch (SQLException e) {
          //
      }
      return mapRet;
}