static List<Map<String,Object>> query(ResultSet rs) throws SQLException {
  List<Map<String,Object>> list=new ArrayList<Map<String,Object>>();
  ResultSetMetaData meta=rs.getMetaData();
  int columnCount=meta.getColumnCount();
  while (rs.next()) {
    HashMap<String,Object> map=new HashMap<String,Object>();
    for (int i=0; i < columnCount; i++) {
      map.put(meta.getColumnLabel(i + 1),rs.getObject(i + 1));
    }
    list.add(map);
  }
  return list;
}

static List < Map < String , Object > > query ( ResultSet rs ) throws SQLException { List < Map < String , Object > > list = new ArrayList < Map < String , Object > > ( ) ; ResultSetMetaData meta = rs . getMetaData ( ) ; int columnCount = meta . getColumnCount ( ) ; while ( rs . next ( ) ) { HashMap < String , Object > map = new HashMap < String , Object > ( ) ; for ( int i = 0 ; i < columnCount ; i ++ ) { map . put ( meta . getColumnLabel ( i + 1 ) , rs . getObject ( i + 1 ) ) ; } list . add ( map ) ; } return list ; }
read a result set .
