Here you can find the source of convertResultSetToMap(final ResultSet rs)
private static Collection<Map<String, Object>> convertResultSetToMap(final ResultSet rs)
//package com.java2s; //License from project: Open Source License import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Map; public class Main { private static Collection<Map<String, Object>> convertResultSetToMap(final ResultSet rs) { try {// w w w. j a v a2s .c o m ResultSetMetaData metaData = rs.getMetaData(); int colum = metaData.getColumnCount(); Collection<Map<String, Object>> collection = new ArrayList<Map<String, Object>>(); Map<String, Object> row = null; while (rs.next()) { row = new HashMap<String, Object>(); for (int i = 0; i < colum; i++) row.put(metaData.getColumnName(i), rs.getObject(i)); collection.add(row); } return collection; } catch (SQLException e) { return null; } finally { try { rs.close(); } catch (SQLException e) { } } } }