arttuladhar
6/28/2013 - 8:37 PM

Converts resultSet to HashMap of Strings and Objects

Converts resultSet to HashMap of Strings and Objects

/**
* <h2> Converts ResultSet to HashMap of List<String,Object></h2>
* @param row
* @param rs_SubItemType
* @throws SQLException
*/

private static void getHashMap( List<Map<String, Object>> row, ResultSet rs_SubItemType) throws SQLException {

ResultSetMetaData metaData = rs_SubItemType.getMetaData();
int colCount = metaData.getColumnCount();

while (rs_SubItemType.next()) {
  Map<String, Object> columns = new HashMap<String, Object>();
  for (int i = 1; i <= colCount; i++) {
    columns.put(metaData.getColumnLabel(i), rs_SubItemType.getObject(i));
  }

  row.add(columns);
  }

}