Java SQL ResultSet putResultSetToMap(final Hashtable map, final ResultSet resultSet, final String... keys)

Here you can find the source of putResultSetToMap(final Hashtable map, final ResultSet resultSet, final String... keys)

Description

Put all the keys from the resultSet into the map using the specified keys.

License

Open Source License

Parameter

Parameter Description
map a parameter
resultSet a parameter
keys a parameter

Exception

Parameter Description
SQLException an exception
Exception an exception

Declaration

public static void putResultSetToMap(final Hashtable<String, String> map, final ResultSet resultSet,
        final String... keys) throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.Hashtable;

public class Main {
    /**/*from   ww w .ja v  a  2  s  .com*/
     * Put all the keys from the resultSet into the map using the specified keys.
     * 
     * @param map
     * @param resultSet
     * @param keys
     * @throws SQLException
     * @throws Exception
     */
    public static void putResultSetToMap(final Hashtable<String, String> map, final ResultSet resultSet,
            final String... keys) throws SQLException {
        for (String key : keys) {
            String val = resultSet.getString(key);
            if (val != null) {
                map.put(key, val);
            }
        }
    }
}

Related

  1. loadListMap(final ResultSet rs)
  2. logCurrentResultSetRow(Log log, String msg, ResultSet rs)
  3. mapResultSet(ResultSet set)
  4. moveToPageNo(ResultSet rs, int pageNo, int pageSize)
  5. parseSqlResultToListMap(ResultSet rs)
  6. safeGetString(ResultSet r, String name)
  7. saveResultsetAsFile(ResultSet rs, String filePath, String fileName)
  8. toXML(ResultSet rs)
  9. writeResultSetToFile(String path, ResultSet results)