Here you can find the source of dumpResultSet(ResultSet rs)
Parameter | Description |
---|---|
rs | result set. |
Parameter | Description |
---|---|
SQLException | if database errors out. |
public static void dumpResultSet(ResultSet rs) throws SQLException
//package com.java2s; // the terms of the GNU General Public License as published by the Free Software Foundation; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class Main { /**/*from w w w . j av a 2 s. c om*/ * Dumps the contents of a result set. * * @param rs result set. * * @throws SQLException if database errors out. */ public static void dumpResultSet(ResultSet rs) throws SQLException { ResultSetMetaData md = rs.getMetaData(); int cc = md.getColumnCount(); int r = 1; while (rs.next()) { System.out.println("Record " + (r++)); for (int i = 1; i <= cc; i++) { System.out.println(" " + md.getColumnName(i) + ": " + rs.getObject(i)); } } } }