Here you can find the source of getListMapFromResultSet(ResultSet rs)
public static ArrayList<Map<String, String>> getListMapFromResultSet(ResultSet rs)
//package com.java2s; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; public class Main { public static ArrayList<Map<String, String>> getListMapFromResultSet(ResultSet rs) { ArrayList<Map<String, String>> myList = new ArrayList<Map<String, String>>(); try {// w w w . j a v a 2 s. com while (rs.next()) { Map<String, String> map = new HashMap<String, String>(); ResultSetMetaData rsmd = rs.getMetaData(); int numColumns = rsmd.getColumnCount(); // get the column names; column indices start from 1 for (int i = 1; i < numColumns + 1; i++) { String columnName = rsmd.getColumnName(i); String columnValue = rs.getString(columnName); map.put(columnName, columnValue); } myList.add(map); } } catch (Exception e) { throw new RuntimeException("Unable to get data for execution", e); } return myList; } }