Java SQL ResultSet Print printRecord(PrintWriter pw, ResultSet rs)

Here you can find the source of printRecord(PrintWriter pw, ResultSet rs)

Description

print Record

License

Open Source License

Declaration

public static void printRecord(PrintWriter pw, ResultSet rs) throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.PrintWriter;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;

public class Main {
    public static void printRecord(PrintWriter pw, ResultSet rs) throws SQLException {
        ResultSetMetaData rsmd = rs.getMetaData();
        printRecord(pw, rs, rsmd);/*from   w w w .j  av a 2  s.  c om*/
    }

    public static void printRecord(PrintWriter pw, ResultSet rs, ResultSetMetaData rsmd) throws SQLException {
        for (int i = 1; i <= rsmd.getColumnCount(); i++) {
            String value = rs.getString(i);
            if (value == null) {
                value = "";
            }
            pw.print((i == 1 ? value : "\t" + value));
        }
        pw.println();
    }
}

Related

  1. printColTypes(ResultSetMetaData rsmd)
  2. printHeader(PrintWriter pw, ResultSet rs)
  3. printHeaders(ResultSetMetaData rsmd, PrintStream out)
  4. printItems(ResultSet rs)
  5. printoutDB(ResultSet rs)
  6. printResult(ResultSet rs)
  7. printResults(final ResultSet results)
  8. printResults(ResultSet rst)
  9. printResultSet(List> rows, List colNames)