Java SQL Table Column getColumnNames(final ResultSet resultSet)

Here you can find the source of getColumnNames(final ResultSet resultSet)

Description

get Column Names

License

Open Source License

Parameter

Parameter Description
resultSet a parameter

Declaration

static List<String> getColumnNames(final ResultSet resultSet) throws SQLException 

Method Source Code

//package com.java2s;
/**/*w ww  .j a  v  a2  s.com*/
 * Copyright (c) 2011 Martin Geisse
 *
 * This file is distributed under the terms of the MIT license.
 */

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

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**
     * @param resultSet
     * @return
     */
    static List<String> getColumnNames(final ResultSet resultSet) throws SQLException {
        final ResultSetMetaData meta = resultSet.getMetaData();
        final List<String> result = new ArrayList<String>();
        for (int i = 0; i < meta.getColumnCount(); i++) {
            result.add(meta.getColumnName(1 + i));
        }
        return result;
    }
}

Related

  1. getColumnIndexFromColumnName(ResultSetMetaData metaData, String columnName)
  2. getColumnLabelMap(ResultSet resultSet)
  3. getColumnMetaData(Connection conn, String table, String column)
  4. getColumnName(boolean isShowRowNum, ResultSet rs)
  5. getColumnName(ResultSetMetaData meta, int column)
  6. getColumnNames(ResultSet resultSet_)
  7. getColumnNames(ResultSet rs)
  8. getColumnNames(ResultSet rs)
  9. getColumnNames(ResultSet rs)