Java SQL Table Column getColumnNamesFromResultSet(ResultSet rs)

Here you can find the source of getColumnNamesFromResultSet(ResultSet rs)

Description

get Column Names From Result Set

License

Open Source License

Declaration

public static String[] getColumnNamesFromResultSet(ResultSet rs)
            throws SQLException 

Method Source Code

//package com.java2s;
/* ***** BEGIN LICENSE BLOCK *****
 *
 * This file is part of Weave./*from w  ww.  ja  v  a2 s  .c  o m*/
 *
 * The Initial Developer of Weave is the Institute for Visualization
 * and Perception Research at the University of Massachusetts Lowell.
 * Portions created by the Initial Developer are Copyright (C) 2008-2015
 * the Initial Developer. All Rights Reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 * 
 * ***** END LICENSE BLOCK ***** */

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

public class Main {
    public static String[] getColumnNamesFromResultSet(ResultSet rs)
            throws SQLException {
        String[] columnNames = new String[rs.getMetaData().getColumnCount()];
        for (int i = 0; i < columnNames.length; i++)
            columnNames[i] = rs.getMetaData().getColumnName(i + 1);
        return columnNames;
    }
}

Related

  1. getColumnNames(final ResultSet resultSet)
  2. getColumnNames(ResultSet resultSet_)
  3. getColumnNames(ResultSet rs)
  4. getColumnNames(ResultSet rs)
  5. getColumnNames(ResultSet rs)
  6. getColumns(ResultSetMetaData rsmd)
  7. getColumns(ResultSetMetaData rsMetaData)
  8. getColumnsNames(ResultSet rs)
  9. getColumnType(ResultSet resultSet, int i, Map typeCache)