Java SQL Table Column getColumnNames(ResultSet rs)

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

Description

Retorna um array de strings com os nomes das colunas de um ResultSet

License

Open Source License

Parameter

Parameter Description
ResultSet rs

Exception

Parameter Description
SQLException an exception

Return

String[]

Declaration

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

Method Source Code

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

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

public class Main {
    /**/*from  w  w  w.j a  v  a 2s  .  c  o m*/
     * Retorna um array de strings com os nomes das colunas de um ResultSet 
     * @param ResultSet rs
     * @return String[]
     * @throws SQLException 
     */
    public static String[] getColumnNames(ResultSet rs) throws SQLException {

        ResultSetMetaData rsmd = rs.getMetaData();
        int numColumns = rsmd.getColumnCount();
        String[] columnNames = new String[numColumns];
        for (int i = 1; i < numColumns + 1; i++)
            columnNames[i - 1] = rsmd.getColumnName(i);
        return columnNames;
    }
}

Related

  1. getColumnName(boolean isShowRowNum, ResultSet rs)
  2. getColumnName(ResultSetMetaData meta, int column)
  3. getColumnNames(final ResultSet resultSet)
  4. getColumnNames(ResultSet resultSet_)
  5. getColumnNames(ResultSet rs)
  6. getColumnNames(ResultSet rs)
  7. getColumnNamesFromResultSet(ResultSet rs)
  8. getColumns(ResultSetMetaData rsmd)
  9. getColumns(ResultSetMetaData rsMetaData)