Java SQL ResultSet to resultSetToArrayList(ResultSet rs)

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

Description

result Set To Array List

License

Open Source License

Declaration

public static List<HashMap> resultSetToArrayList(ResultSet rs) throws SQLException 

Method Source Code


//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.HashMap;
import java.util.List;

public class Main {

    public static List<HashMap> resultSetToArrayList(ResultSet rs) throws SQLException {
        ResultSetMetaData md = rs.getMetaData();
        int columns = md.getColumnCount();
        ArrayList list = new ArrayList();
        while (rs.next()) {
            HashMap row = new HashMap(columns);
            for (int i = 1; i <= columns; ++i) {
                row.put(md.getColumnName(i), rs.getObject(i));
            }/*w w  w  .ja va  2  s .  co m*/
            list.add(row);
        }

        return list;
    }
}

Related

  1. resultSet2List(ResultSet rs)
  2. resultSet2Map(ResultSet rs)
  3. resultSetAsCSV(ResultSet rsh)
  4. resultSetCurrentData(ResultSet rs)
  5. resultSetParseVO(ResultSet rs, Class cls)
  6. resultSetToHtmlTable(java.sql.ResultSet rs)
  7. resultSetToMap(Map mappedValues, java.sql.ResultSet rs, int key, int value)
  8. resultSetToMap(Map mappedValues, ResultSet rs)
  9. resultSetToOrderedMap(ResultSet rs)