Java Utililty Methods SQL ResultSet Print

List of utility methods to do SQL ResultSet Print

Description

The list of methods to do SQL ResultSet Print are organized into topic(s).

Method

voidprintRecord(PrintWriter pw, ResultSet rs)
print Record
ResultSetMetaData rsmd = rs.getMetaData();
printRecord(pw, rs, rsmd);
voidprintResult(ResultSet rs)
print Result
ResultSetMetaData rsmd = (ResultSetMetaData) rs.getMetaData();
int colNum = rsmd.getColumnCount();
while (rs.next()) {
    for (int i = 0; i < colNum; i++)
        System.out.printf(rs.getString(i + 1) + " ");
    System.out.println();
voidprintResults(final ResultSet results)
print Results
while (results.next()) {
    final ResultSetMetaData meta = results.getMetaData();
    final int colCnt = meta.getColumnCount();
    for (int i = 1; i <= colCnt; ++i) {
        final String str = results.getString(i);
        System.out.print(meta.getColumnName(i) + ":" + str + " ");
    System.out.println();
...
intprintResults(ResultSet rst)
Helper method to print out the resultSet.
ResultSetMetaData meta = rst.getMetaData();
int numColumns = meta.getColumnCount();
System.out.print(meta.getColumnName(1));
for (int j = 2; j <= meta.getColumnCount(); j++)
    System.out.print(", " + meta.getColumnName(j));
System.out.println();
int count = 0;
while (rst.next()) {
...
StringprintResultSet(List> rows, List colNames)
print Result Set
StringBuffer out = new StringBuffer();
char delim = '\t';
for (String name : colNames) {
    out.append(name).append(delim);
if (out.length() > 0)
    out.delete(out.length() - 1, out.length());
out.append('\n');
...
StringprintResultSet(ResultSet rs)
print Result Set
StringBuilder sb = new StringBuilder();
try {
    ResultSetMetaData rsMeta = rs.getMetaData();
    int colCount = rsMeta.getColumnCount();
    int count = 0;
    while (rs.next()) {
        sb.append(count++);
        sb.append("-------------------------------------------------------\r\n");
...
voidprintResultSet(ResultSet rs)
print Result Set
PrintWriter pw = new PrintWriter(System.out);
printResultSet(rs, 100, true, pw);
pw.flush();
voidprintResultSet(ResultSet rs)
Print a ResultSet to System.out.
ResultSetMetaData rsmd = rs.getMetaData();
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
    if (i != 1) {
        System.out.print(", ");
    System.out.print(rsmd.getColumnName(i));
System.out.println();
...
voidprintResultSet(ResultSet rs)
print Result Set
printResultSet(rs, System.out);
voidprintResultSet(ResultSet rs)
print Result Set
ResultSetMetaData metaData = rs.getMetaData();
int numColumns = printResultSetHeader(metaData);
while (rs.next()) {
    printResultSetRow(rs, numColumns);