Java SQL ResultSet Read getEntityMap(ResultSet rs, ResultSetMetaData rsmd)

Here you can find the source of getEntityMap(ResultSet rs, ResultSetMetaData rsmd)

Description

get Entity Map

License

Open Source License

Declaration

public static Map<String, Object> getEntityMap(ResultSet rs, ResultSetMetaData rsmd) throws SQLException 

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> getEntityMap(ResultSet rs, ResultSetMetaData rsmd) throws SQLException {

        Map<String, Object> entity = new HashMap<>();

        int colCount = rsmd.getColumnCount();

        for (int i = 0; i < colCount; i++) {
            String colName = rsmd.getColumnLabel(i + 1).toUpperCase();
            Object colValue = rs.getObject(colName);

            entity.put(colName, colValue);
        }/*from ww  w  .  j  a v  a2s .c om*/

        return entity;
    }
}

Related

  1. getDataDupls(ResultSet rs)
  2. getDateList(ResultSet resultSet, String columnName)
  3. getDbDateValue(ResultSet rs, String columnName)
  4. getDebugData(ResultSet rs)
  5. getDuplicacy(ResultSet rs)
  6. getEnum(Class enumClass, ResultSet rs, String columnName)
  7. getEnum(ResultSet r, String columnName, Class enumType)
  8. getEnum(ResultSet rs, int index, Class type)
  9. getEnumFromResultSet(ResultSet rset, Enum field, T[] enumValues)