Java SQL ResultSet Print printHeaders(ResultSetMetaData rsmd, PrintStream out)

Here you can find the source of printHeaders(ResultSetMetaData rsmd, PrintStream out)

Description

print Headers

License

Open Source License

Declaration

private static void printHeaders(ResultSetMetaData rsmd, PrintStream out) throws SQLException 

Method Source Code


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

import java.io.PrintStream;

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

public class Main {
    private static void printHeaders(ResultSetMetaData rsmd, PrintStream out) throws SQLException {
        StringBuilder sb = new StringBuilder();
        sb.append("| ");
        for (int i = 1; i <= rsmd.getColumnCount(); i++) {
            sb.append(rsmd.getColumnLabel(i)).append(" | ");
        }//from  ww w.  j av  a 2s .co m
        sb.append('\n');

        for (int i = 0; i < sb.length(); i++)
            out.print('-');
        out.print('\n');
        out.print(sb.toString());
        for (int i = 0; i < sb.length(); i++)
            out.print('-');
        out.print('\n');
    }
}

Related

  1. print(ResultSet rs, PrintStream out)
  2. print(ResultSet rs, PrintStream out)
  3. printCols(final ResultSetMetaData paymentTableResultSetMetaData, final String logging_prefix)
  4. printColTypes(ResultSetMetaData rsmd)
  5. printHeader(PrintWriter pw, ResultSet rs)
  6. printItems(ResultSet rs)
  7. printoutDB(ResultSet rs)
  8. printRecord(PrintWriter pw, ResultSet rs)
  9. printResult(ResultSet rs)