Java SQL ResultSet Read getResultByMap(ResultSet rs)

Here you can find the source of getResultByMap(ResultSet rs)

Description

get Result By Map

License

Apache License

Declaration

private static List<Object> getResultByMap(ResultSet rs) throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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;

public class Main {

    private static List<Object> getResultByMap(ResultSet rs) throws SQLException {
        List<Object> list = new ArrayList<Object>();
        ResultSetMetaData rsmData = rs.getMetaData();
        while (rs.next()) {
            Map<Object, Object> map = new HashMap<Object, Object>();
            for (int i = 1; i <= rsmData.getColumnCount(); i++) {
                map.put(rsmData.getColumnName(i), rs.getObject(i));
            }//  w  ww. j a v  a  2 s .co  m
            list.add(map);
        }
        return list;
    }
}

Related

  1. getOptionalInt(ResultSet rs, String name)
  2. getPath(ResultSet r, String columnName)
  3. getRecordsFromResultSet(ResultSet rs)
  4. getResult(ResultSet rs)
  5. getResultArray(ResultSet resultSet, int size, java.util.Date startDate)
  6. getResults(ResultSet result)
  7. getResultsAsMap(ResultSet rs)
  8. getResultSet(Connection c, String query)
  9. getResultSet(Connection conn, String query)