Here you can find the source of print(ResultSet rs, PrintStream out)
Parameter | Description |
---|---|
rs | ResultSet instance |
Parameter | Description |
---|---|
SQLException | an exception |
public static void print(ResultSet rs, PrintStream out) throws SQLException
//package com.java2s; //License from project: Open Source License import java.io.PrintStream; import java.sql.*; public class Main { /**//from www .jav a 2 s .c o m * Prints data contained in provided {@link ResultSet} instance as tab-separated table; first line will contain column * names. Mainly for debug purposes, quite easy to copy-paste output to spreadsheet application * * @param rs {@link ResultSet} instance * @throws SQLException */ public static void print(ResultSet rs, PrintStream out) throws SQLException { final ResultSetMetaData metaData = rs.getMetaData(); final int count = metaData.getColumnCount(); for (int i = 1; i <= count; i++) { out.print(metaData.getColumnName(i) + "\t"); } out.println(); while (rs.next()) { for (int i = 1; i <= count; i++) { out.print(rs.getObject(i) + "\t"); } out.println(); } } }