All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.testing.jdbc.ResultSetUtil Maven / Gradle / Ivy

There is a newer version: 7.0.0.Beta1
Show newest version
/*
 * 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 .
 */
package org.hibernate.testing.jdbc;

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

/**
 * @author Steve Ebersole
 */
public class ResultSetUtil {
	public static List> extractResults(ResultSet resultSet) throws SQLException {
		List> results = new ArrayList>();

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

		return results;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy