Java SQL ResultSet to toArrayList(ResultSet rs)

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

Description

to Array List

License

Apache License

Declaration

@SuppressWarnings("unchecked")
    public static List toArrayList(ResultSet rs) 

Method Source Code

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

import java.sql.ResultSet;
import java.util.ArrayList;

import java.util.List;

public class Main {
    @SuppressWarnings("unchecked")
    public static List toArrayList(ResultSet rs) {
        List arrayList = null;/*from   w ww.  jav  a  2  s  .  com*/
        try {
            arrayList = new ArrayList();
            int iCol = rs.getMetaData().getColumnCount();
            while (rs.next()) {
                Object[] objArray = new Object[iCol];
                for (int i = 1; i <= iCol; i++) {
                    objArray[i - 1] = rs.getObject(i);
                }
                arrayList.add(objArray);
            }
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }

        return arrayList;
    }
}

Related

  1. resultSetToOrderedMap(ResultSet rs)
  2. resultSetToSet(PreparedStatement statement)
  3. resultSetToString(ResultSet resultSet)
  4. resultSetToString(ResultSet resultSet)
  5. resultSetToXML(ResultSet rs)
  6. toAttributeMap(ResultSet resultSet)
  7. toJSONFromResultSet(ResultSet resultSet)
  8. toListMap(int limit, ResultSet rs)
  9. toMap(final ResultSet resultSet)