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

StringprettyFormat(ResultSet res)
pretty Format
StringBuilder sb = new StringBuilder();
ResultSetMetaData rsmd = res.getMetaData();
int numOfColumns = rsmd.getColumnCount();
for (int i = 1; i <= numOfColumns; i++) {
    if (i > 1)
        sb.append(",  ");
    String columnName = rsmd.getColumnName(i);
    sb.append(columnName);
...
voidprint(ResultSet resultSet)
print
try {
    ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
    int columnsNumber = resultSetMetaData.getColumnCount();
    while (resultSet.next()) {
        for (int i = 1; i <= columnsNumber; i++) {
            if (i > 1)
                System.out.print(",  ");
            String columnValue = resultSet.getString(i);
...
voidprint(ResultSet rs, PrintStream out)
Prints data contained in provided ResultSet instance as tab-separated table; first line will contain column names.
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++) {
...
voidprint(ResultSet rs, PrintStream out)
Prints a ResultSet.
ResultSetMetaData meta = rs.getMetaData();
int columns = meta.getColumnCount();
for (int i = 0; i < columns; i++) {
    if (i > 0) {
        out.print(",");
    out.print("\"");
    out.print(meta.getColumnName(i + 1));
...
voidprintCols(final ResultSetMetaData paymentTableResultSetMetaData, final String logging_prefix)
print Cols
System.out.println(logging_prefix);
for (int i = 1; i <= paymentTableResultSetMetaData.getColumnCount(); i++) {
    System.out.print(paymentTableResultSetMetaData.getColumnName(i) + "\t");
System.out.println("\n");
voidprintColTypes(ResultSetMetaData rsmd)
print Col Types
int columns = rsmd.getColumnCount();
for (int i = 1; i <= columns; i++) {
    int jdbcType = rsmd.getColumnType(i);
    String name = rsmd.getColumnTypeName(i);
voidprintHeader(PrintWriter pw, ResultSet rs)
print Header
ResultSetMetaData rsmd = rs.getMetaData();
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
    pw.print((i == 1 ? rsmd.getColumnName(i) : "\t" + rsmd.getColumnName(i)));
pw.println();
voidprintHeaders(ResultSetMetaData rsmd, PrintStream out)
print Headers
StringBuilder sb = new StringBuilder();
sb.append("| ");
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
    sb.append(rsmd.getColumnLabel(i)).append(" | ");
sb.append('\n');
for (int i = 0; i < sb.length(); i++)
    out.print('-');
...
voidprintItems(ResultSet rs)
print Items
try {
    int columns = rs.getMetaData().getColumnCount();
    for (int i = 0; i < columns; i++) {
        System.out.println(i + ": " + rs.getObject(i + 1));
} catch (SQLException sqle) {
    sqle.printStackTrace();
voidprintoutDB(ResultSet rs)
printout DB
ResultSetMetaData meta = rs.getMetaData();
int cols = meta.getColumnCount() + 1;
while (rs.next()) {
    System.out.println("=== ROW START ===");
    for (int i = 1; i < cols; i++) {
        System.out.println(meta.getColumnName(i) + ": " + rs.getString(i));
    System.out.println("=== ROW END ===");
...