Java SQL Table Column toColumnNameList(final ResultSet rs)

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

Description

to Column Name List

License

Apache License

Declaration

private static List<String> toColumnNameList(final ResultSet rs)
        throws SQLException 

Method Source Code

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

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class Main {

    private static List<String> toColumnNameList(final ResultSet rs)
            throws SQLException {
        final Map<Integer, String> columnNames = new TreeMap<Integer, String>();
        while (rs.next()) {
            columnNames.put(rs.getInt("ORDINAL_POSITION"),
                    rs.getString("COLUMN_NAME"));
        }//  www.ja  v a 2  s  .  c  o  m
        return new ArrayList<String>(columnNames.values());
    }
}

Related

  1. resultSetToStringFormat(ResultSet rs, String separator, String quote, boolean column)
  2. resultSetValue(ResultSet resultSet, Class parameterClass, Object object, String columnLabel)
  3. retrieveCoulmns(String tableName, String columnArray[], Statement statement, long offset, long numberOfRecords)
  4. tableContainsColumn(Connection conn, String table, String column)
  5. tableContainsIndex(Connection conn, String table, String column, String index)
  6. toFlag(ResultSetMetaData metaData, int column)
  7. toFormatList(ResultSet results, List column)
  8. toMap(ResultSet rs, List wantedColumnNames)
  9. toValuesList(ResultSet results, String column)