Java SQL ResultSet extractResults(ResultSet resultSet)

Here you can find the source of extractResults(ResultSet resultSet)

Description

extract Results

License

LGPL

Declaration

public static List<Map<String, ?>> extractResults(ResultSet resultSet) throws SQLException 

Method Source Code


//package com.java2s;
/*/*w  w w .j a v a  2 s  .c om*/
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {
    public static List<Map<String, ?>> extractResults(ResultSet resultSet) throws SQLException {
        List<Map<String, ?>> results = new ArrayList<Map<String, ?>>();

        while (resultSet.next()) {
            Map<String, Object> row = new HashMap<String, Object>();
            for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
                row.put(resultSet.getMetaData().getColumnLabel(i), resultSet.getObject(i));
                results.add(row);
            }
        }

        return results;
    }
}

Related

  1. createTable(ResultSet rs)
  2. createUid(final String[] keys, final ResultSet rs, final String keySeparator)
  3. encodeHeader(ResultSetMetaData metaData)
  4. extractGeneratedId(ResultSet generatedKeys)
  5. extractIntResult(ResultSet rs, ResultSetMetaData rsmd, int index)
  6. extractResultSetFiledNames(ResultSet result)
  7. fillRowNames(Map metaData, ResultSet rs)
  8. hasCompleted(ResultSet rs)
  9. hasGeometryField(ResultSet resultSet)