Java SQL ResultSet Read getMap(ResultSet resultSet)

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

Description

get Map

License

Open Source License

Declaration

public static Map<String, Object> getMap(ResultSet resultSet) 

Method Source Code


//package com.java2s;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;

import java.util.HashMap;

import java.util.Map;

public class Main {

    public static Map<String, Object> getMap(ResultSet resultSet) {
        Map<String, Object> valueMap = new HashMap<String, Object>();
        try {/*from   w  w  w  .  j a va 2s . co  m*/
            ResultSetMetaData metaData = resultSet.getMetaData();
            int columnCount = metaData.getColumnCount();
            for (int j = 1; j <= columnCount; j++) {
                valueMap.put(metaData.getColumnLabel(j), resultSet.getObject(j));
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return valueMap;
    }
}

Related

  1. getList(ResultSet rs)
  2. getListFromRS(Class clazz, ResultSet rs)
  3. getListMapFromResultSet(ResultSet rs)
  4. getLocalDate(ResultSet res, String name)
  5. getLocalDate(ResultSet rs, String columnName)
  6. getMap(ResultSet resultSet)
  7. getMap(ResultSet rs, ResultSetMetaData metaData, int cols_len)
  8. getMetaData(ResultSet rs)
  9. getNullable(final ResultSet resultSet, final T value)