Here you can find the source of resultSet2Map(ResultSet rs)
private static Map<String, Object> resultSet2Map(ResultSet rs)
//package com.java2s; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.HashMap; import java.util.Map; import com.google.common.base.Strings; public class Main { 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)); }//from w ww. j a v a2 s. c o m } } catch (SQLException e) { e.printStackTrace(); } } return map; } }