Converting Result Set to HashMap
28 Jun 2013
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* <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); | |
} | |
} |