Here you can find the source of resultSet2List(ResultSet rs)
private static List<Map<String, Object>> resultSet2List(ResultSet rs)
//package com.java2s; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import com.google.common.base.Strings; public class Main { private static List<Map<String, Object>> resultSet2List(ResultSet rs) { List<Map<String, Object>> list = null; if (rs != null) { list = new ArrayList<Map<String, Object>>(); try { while (rs.next()) { Map<String, Object> map = resultSet2Map(rs); if (map != null && map.size() > 0) { list.add(map);/*from w w w. ja va 2 s. c o m*/ } } } catch (Exception e) { e.printStackTrace(); } } return list; } private static Map<String, Object> resultSet2Map(ResultSet rs) { Map<String, Object> map = null; if (rs != null) { map = new HashMap<String, Object>(); try { ResultSetMetaData rsMetaData = rs.getMetaData(); int columnCount = rsMetaData.getColumnCount(); for (int i = 1; i <= columnCount; i++) { String cName = rsMetaData.getColumnLabel(i); if (!Strings.isNullOrEmpty(cName)) { map.put(cName, rs.getString(cName)); } } } catch (SQLException e) { e.printStackTrace(); } } return map; } }