Here you can find the source of getAllValueMaps(ResultSet input)
Parameter | Description |
---|---|
input | a parameter |
validFrom | a parameter |
Parameter | Description |
---|---|
SQLException | an exception |
public static List<Map<String, String>> getAllValueMaps(ResultSet input) throws SQLException, IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class Main { /**/*from w ww .j a va 2 s. c o m*/ * Get a List of Maps containing the rows of the ResultSet with a matching valid date * information. This is needed as we can not make constraints on a date represented as string in * the db. * * @param input * @param validFrom * @return * @throws SQLException */ public static List<Map<String, String>> getAllValueMaps(ResultSet input) throws SQLException, IOException { List<Map<String, String>> ret = new ArrayList<Map<String, String>>(); // build list of column names ArrayList<String> headers = new ArrayList<String>(); ResultSetMetaData meta = input.getMetaData(); int metaLength = meta.getColumnCount(); for (int i = 1; i <= metaLength; i++) { headers.add(meta.getColumnName(i)); } // find rows with matching valid date information while (input.next()) { HashMap<String, String> valuesMap = new HashMap<String, String>(); // put all the columns with values into valuesMap for (String columnName : headers) { String value = input.getString(columnName); valuesMap.put(columnName, value); } // add map to list of matching maps ret.add(valuesMap); } return ret; } }