Java SQL ResultSet Dump dumpResultSet(ResultSet rs)

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

Description

Dumps the contents of a result set.

License

Open Source License

Parameter

Parameter Description
rs result set.

Exception

Parameter Description
SQLException if database errors out.

Declaration

public static void dumpResultSet(ResultSet rs) throws SQLException 

Method Source Code

//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));
            }
        }
    }
}

Related

  1. dump(ResultSet rset)
  2. dump(ResultSet set)
  3. dumpResultSet(ResultSet dbResult)
  4. dumpResultSet(ResultSet resultSet, String tablename, String[] columns)
  5. dumpResultSet(ResultSet rs)
  6. dumpResultSetMetaData(ResultSet dbResult)
  7. dumpRs(ResultSet rs, PrintWriter out, String delimiter, boolean printTrailingDelimiter)