Java SQL ResultSet Read readMap(final ResultSet rs)

Here you can find the source of readMap(final ResultSet rs)

Description

read Map

License

Apache License

Declaration

public static Map<String, Object> readMap(final ResultSet rs) throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

import java.util.LinkedHashMap;

import java.util.Map;

public class Main {
    public static Map<String, Object> readMap(final ResultSet rs) throws SQLException {
        final Map<String, Object> values = new LinkedHashMap<>();
        final ResultSetMetaData metaData = rs.getMetaData();
        for (int i = 1; i <= metaData.getColumnCount(); i++) {
            final String name = metaData.getColumnName(i);
            final Object value = rs.getObject(i);
            values.put(name, value);//from  w  w  w .  j  a  v a  2  s  . c o m
        }
        return values;
    }
}

Related

  1. getValueByObjectType(ResultSetMetaData metaData, ResultSet rs, int index)
  2. getValueFromResultSet(int index, final ResultSet resultSet, final Class type)
  3. readBitBoolean(ResultSet result, int index)
  4. readBytes(ResultSet rs, int pos)
  5. readDate(ResultSet result, int index)
  6. readObject(java.sql.ResultSet resultSet, int index)
  7. readResults(ResultSet resultSet)
  8. wasNull(ResultSet rs, T value)
  9. wasNull(ResultSet rs, T value)