Here you can find the source of getColumnNames(ResultSet rs)
Parameter | Description |
---|---|
ResultSet | rs |
Parameter | Description |
---|---|
SQLException | an exception |
public static String[] getColumnNames(ResultSet rs) throws SQLException
//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; } }