Java SQL Table Column getColumnLabelMap(ResultSet resultSet)

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

Description

get Column Label Map

License

Open Source License

Declaration

public static Map<String, Integer> getColumnLabelMap(ResultSet resultSet) 

Method Source Code

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

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

import java.util.HashMap;

import java.util.Map;

public class Main {

    public static Map<String, Integer> getColumnLabelMap(ResultSet resultSet) {
        Map<String, Integer> map = new HashMap<String, Integer>();
        try {//from w  w  w.j a v  a  2 s .c  o  m
            ResultSetMetaData rsmd = resultSet.getMetaData();
            int columnCount = rsmd.getColumnCount();
            for (int i = 1; i <= columnCount; i++) {
                map.put(rsmd.getColumnLabel(i), 1);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return map;
    }

    public static int getColumnCount(ResultSet resultSet) {
        int columnCount = -1;
        try {
            ResultSetMetaData rsmd = resultSet.getMetaData();
            columnCount = rsmd.getColumnCount();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return columnCount;
    }
}

Related

  1. generateKey(Statement statement, String TableName, String KeyColumn)
  2. getAllFromSensorDb( final Connection jdbcConnection, final String tableName, final String orderByColumn)
  3. getColumn(ResultSet result, int col)
  4. getColumnDisplaySize(int col, ResultSetMetaData rsmd)
  5. getColumnIndexFromColumnName(ResultSetMetaData metaData, String columnName)
  6. getColumnMetaData(Connection conn, String table, String column)
  7. getColumnName(boolean isShowRowNum, ResultSet rs)
  8. getColumnName(ResultSetMetaData meta, int column)
  9. getColumnNames(final ResultSet resultSet)