Java JDBC Metadata Holds Query Column Names
Java JDBC code to find column names in a query.
private Connection mAccess; private Statement mStatement; private ResultSet mResultSet; private ResultSetMetaData mResultSetMetaData; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); mAccess = DriverManager.getConnection("jdbc:odbc:pma_boeing"); mStatement = mAccess.createStatement(); ResultSet mResultSet = mStatement.executeQuery("Select top 10 * from boeing"); mResultSetMetaData = mResultSet.getMetaData(); int TotalColumn = mResultSetMetaData.getColumnCount(); for (int j = 1; j <= TotalColumn; j++) { System.out.println("[" + j + "] " + mResultSetMetaData.getColumnName(j)); }