Here you can find the source of getAllColumnNamesFromResultSet(ResultSet set)
Parameter | Description |
---|---|
set | the ResultSet to get the columns from. |
Parameter | Description |
---|---|
SQLException | if something goes wrong. |
public static String[] getAllColumnNamesFromResultSet(ResultSet set) throws SQLException
//package com.java2s; /******************************************************************************* * Copyright (c) 2013-2014 Black Rook Software * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html ******************************************************************************/ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class Main { /**//from www . j a v a 2 s . c o m * Returns the names of the columns in a ResultSet in the order that they appear in the result. * @param set the ResultSet to get the columns from. * @return an array of all of the columns. * @throws SQLException if something goes wrong. */ public static String[] getAllColumnNamesFromResultSet(ResultSet set) throws SQLException { ResultSetMetaData md = set.getMetaData(); String[] out = new String[md.getColumnCount()]; for (int i = 0; i < out.length; i++) out[i] = md.getColumnName(i + 1); return out; } }