Here you can find the source of consume2(ResultSet rs)
private static Map[] consume2(ResultSet rs) throws Exception
//package com.java2s; /******************************************************************************* * xFramium//w w w .j a v a 2s.c o m * * Copyright 2016 by Moreland Labs, Ltd. (http://www.morelandlabs.com) * * Some open source application is free software: you can redistribute * it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation, either * version 3 of the License, or (at your option) any later version. * * Some open source application is distributed in the hope that it will * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with xFramium. If not, see <http://www.gnu.org/licenses/>. * * @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+> *******************************************************************************/ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.HashMap; public class Main { private static final Map[] EMPTY_MAP_ARRAY = new Map[0]; private static Map[] consume2(ResultSet rs) throws Exception { ResultSetMetaData rsmd = rs.getMetaData(); ArrayList results = new ArrayList(); int colCount = rsmd.getColumnCount(); while (rs.next()) { Map row = new HashMap(); for (int i = 1; i <= colCount; ++i) { Object val = rs.getObject(i); row.put(rsmd.getColumnName(i), val); row.put(i, val); } results.add(row); } return toOutArray2(results); } private static Map[] toOutArray2(List listOfMaps) { return (Map[]) listOfMaps.toArray(EMPTY_MAP_ARRAY); } }