org.apache.derby.tools
Class JDBCDisplayUtil

java.lang.Object
  extended byorg.apache.derby.tools.JDBCDisplayUtil

public class JDBCDisplayUtil
extends java.lang.Object

This class contains utility methods for displaying JDBC objects and results.

All of the methods are static. The output stream to write to is always passed in, along with the JDBC objects to display.

Author:
ames

Field Summary
private static int MAX_RETRIES
           
private static int maxWidth
           
private static int MINWIDTH
           
static boolean showSelectCount
           
 
Constructor Summary
JDBCDisplayUtil()
           
 
Method Summary
static void checkNotNull(java.lang.Object o, java.lang.String what)
          Check if an object is null, and if it is, throw an exception with an informative parameter about what was null.
static int DisplayBanner(java.io.PrintStream out, java.sql.ResultSetMetaData rsmd)
           
static int DisplayBanner(java.io.PrintWriter out, java.sql.ResultSetMetaData rsmd)
          Print a banner containing the column labels separated with '|'s and a line of '-'s.
static void DisplayCurrentRow(java.io.PrintStream out, java.sql.ResultSet rs, java.sql.Connection conn)
           
static void DisplayCurrentRow(java.io.PrintWriter out, java.sql.ResultSet rs, java.sql.Connection conn)
          Display the current row of the result set along with a banner.
private static void DisplayNestedResults(java.io.PrintStream out, java.util.Vector nr, java.sql.Connection conn, int indentLevel)
           
private static void DisplayNestedResults(java.io.PrintWriter out, java.util.Vector nr, java.sql.Connection conn, int indentLevel)
           
static void DisplayNextRow(java.io.PrintStream out, java.sql.ResultSet rs, java.sql.Connection conn)
           
static void DisplayNextRow(java.io.PrintWriter out, java.sql.ResultSet rs, java.sql.Connection conn)
          Fetch the next row of the result set, and if it exists format and display a banner and the row.
static void DisplayResults(java.io.PrintStream out, java.sql.ResultSet rs, java.sql.Connection conn)
           
static void DisplayResults(java.io.PrintStream out, java.sql.Statement stmt, java.sql.Connection conn)
           
static void DisplayResults(java.io.PrintWriter out, java.sql.ResultSet rs, java.sql.Connection conn)
           
static void DisplayResults(java.io.PrintWriter out, java.sql.Statement stmt, java.sql.Connection conn)
          Pretty-print the results of a statement that has been executed.
private static void DisplayRow(java.io.PrintStream out, java.sql.ResultSet rs, java.sql.ResultSetMetaData rsmd, int rowLen, java.util.Vector nestedResults, java.sql.Connection conn, int indentLevel)
           
private static void DisplayRow(java.io.PrintWriter out, java.sql.ResultSet rs, java.sql.ResultSetMetaData rsmd, int rowLen, java.util.Vector nestedResults, java.sql.Connection conn, int indentLevel)
          Print one row of a result set, padding each field to the display width and separating them with '|'s
(package private) static void DisplayUpdateCount(java.io.PrintStream out, int count, int indentLevel)
           
(package private) static void DisplayUpdateCount(java.io.PrintWriter out, int count, int indentLevel)
           
static void doTrace(java.io.PrintStream out, java.lang.Exception e)
           
static void doTrace(java.io.PrintWriter out, java.lang.Exception e)
          If the property ij.exceptionTrace is true, display the stack trace to the print stream.
private static int indent_DisplayBanner(java.io.PrintStream out, java.sql.ResultSetMetaData rsmd, int indentLevel)
           
private static int indent_DisplayBanner(java.io.PrintWriter out, java.sql.ResultSetMetaData rsmd, int indentLevel)
           
private static void indent_DisplayCurrentRow(java.io.PrintStream out, java.sql.ResultSet rs, java.sql.Connection conn, int indentLevel)
           
private static void indent_DisplayCurrentRow(java.io.PrintWriter out, java.sql.ResultSet rs, java.sql.Connection conn, int indentLevel)
           
private static void indent_DisplayNextRow(java.io.PrintStream out, java.sql.ResultSet rs, java.sql.Connection conn, int indentLevel)
           
private static void indent_DisplayNextRow(java.io.PrintWriter out, java.sql.ResultSet rs, java.sql.Connection conn, int indentLevel)
           
private static void indent_DisplayResults(java.io.PrintStream out, java.sql.ResultSet rs, java.sql.Connection conn, int indentLevel)
           
private static void indent_DisplayResults(java.io.PrintStream out, java.sql.Statement stmt, java.sql.Connection conn, int indentLevel)
           
private static void indent_DisplayResults(java.io.PrintWriter out, java.sql.ResultSet rs, java.sql.Connection conn, int indentLevel)
           
private static void indent_DisplayResults(java.io.PrintWriter out, java.sql.Statement stmt, java.sql.Connection conn, int indentLevel)
           
private static void indent(java.io.PrintStream out, int indentLevel)
           
private static void indent(java.io.PrintWriter out, int indentLevel)
           
private static void indentedPrintLine(java.io.PrintStream out, int indentLevel, java.lang.String text)
           
private static void indentedPrintLine(java.io.PrintStream out, int indentLevel, java.lang.StringBuffer text)
           
private static void indentedPrintLine(java.io.PrintWriter out, int indentLevel, java.lang.String text)
           
private static void indentedPrintLine(java.io.PrintWriter out, int indentLevel, java.lang.StringBuffer text)
           
static boolean init()
          init method - will init the class to support a locale and codeset based on the derby.ui.locale and derby.ui.codeset properties if exists or using the default values from the JVM.
static boolean init(java.lang.String codeset)
          init method - will init the class to support a locale and codeset based on the derby.ui.locale properties and on the given codeset if exists or using the default values from the JVM.
static boolean init(java.lang.String pCodeset, java.lang.String pLocale)
          init method - will init the class to support a locale and codeset based on the given codeset and locale.
static java.lang.String mapNull(java.lang.String s, java.lang.String nullValue)
          Map the string to the value if it is null.
static void setMaxDisplayWidth(int maxDisplayWidth)
           
static void ShowException(java.io.PrintStream out, java.lang.Throwable e)
           
static void ShowException(java.io.PrintWriter out, java.lang.Throwable e)
          Print information about the exception to the given PrintWriter.
static void ShowSQLException(java.io.PrintStream out, java.sql.SQLException e)
           
static void ShowSQLException(java.io.PrintWriter out, java.sql.SQLException e)
          Print information about the SQL exception to the given PrintWriter.
static void ShowWarnings(java.io.PrintStream out, java.sql.Connection theConnection)
           
static void ShowWarnings(java.io.PrintStream out, java.sql.ResultSet rs)
           
static void ShowWarnings(java.io.PrintStream out, java.sql.SQLWarning warning)
           
static void ShowWarnings(java.io.PrintStream out, java.sql.Statement s)
           
static void ShowWarnings(java.io.PrintWriter out, java.sql.Connection theConnection)
          Print information about the SQL warnings for the connection to the given PrintWriter.
static void ShowWarnings(java.io.PrintWriter out, java.sql.ResultSet rs)
          Print information about the SQL warnings for the ResultSet to the given PrintWriter.
static void ShowWarnings(java.io.PrintWriter out, java.sql.SQLWarning warning)
           
static void ShowWarnings(java.io.PrintWriter out, java.sql.Statement s)
          Print information about the SQL warnings for the Statement to the given PrintWriter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINWIDTH

private static final int MINWIDTH
See Also:
Constant Field Values

maxWidth

private static int maxWidth

showSelectCount

public static boolean showSelectCount

MAX_RETRIES

private static final int MAX_RETRIES
See Also:
Constant Field Values
Constructor Detail

JDBCDisplayUtil

public JDBCDisplayUtil()
Method Detail

init

public static boolean init()
init method - will init the class to support a locale and codeset based on the derby.ui.locale and derby.ui.codeset properties if exists or using the default values from the JVM.


init

public static boolean init(java.lang.String codeset)
init method - will init the class to support a locale and codeset based on the derby.ui.locale properties and on the given codeset if exists or using the default values from the JVM.


init

public static boolean init(java.lang.String pCodeset,
                           java.lang.String pLocale)
init method - will init the class to support a locale and codeset based on the given codeset and locale. If the parameters are null it will try to init use derby.ui.locale and derby.ui.codeset properties if exists or using the default values from the JVM.


ShowException

public static void ShowException(java.io.PrintWriter out,
                                 java.lang.Throwable e)
Print information about the exception to the given PrintWriter. For non-SQLExceptions, does a stack trace. For SQLExceptions, print a standard error message and walk the list, if any.

Parameters:
out - the place to write to
e - the exception to display

ShowSQLException

public static void ShowSQLException(java.io.PrintWriter out,
                                    java.sql.SQLException e)
Print information about the SQL exception to the given PrintWriter. Walk the list of exceptions, if any.

Parameters:
out - the place to write to
e - the exception to display

ShowWarnings

public static void ShowWarnings(java.io.PrintWriter out,
                                java.sql.Connection theConnection)
Print information about the SQL warnings for the connection to the given PrintWriter. Walks the list of exceptions, if any.

Parameters:
out - the place to write to
theConnection - the connection that may have warnings.

ShowWarnings

public static void ShowWarnings(java.io.PrintWriter out,
                                java.sql.SQLWarning warning)
Parameters:
out - the place to write to
warning - the SQLWarning

ShowWarnings

public static void ShowWarnings(java.io.PrintWriter out,
                                java.sql.ResultSet rs)
Print information about the SQL warnings for the ResultSet to the given PrintWriter. Walk the list of exceptions, if any.

Parameters:
out - the place to write to
rs - the ResultSet that may have warnings on it

ShowWarnings

public static void ShowWarnings(java.io.PrintWriter out,
                                java.sql.Statement s)
Print information about the SQL warnings for the Statement to the given PrintWriter. Walks the list of exceptions, if any.

Parameters:
out - the place to write to
s - the Statement that may have warnings on it

DisplayResults

public static void DisplayResults(java.io.PrintWriter out,
                                  java.sql.Statement stmt,
                                  java.sql.Connection conn)
                           throws java.sql.SQLException
Pretty-print the results of a statement that has been executed. If it is a select, gathers and prints the results. Display partial results up to the first error. If it is not a SELECT, determine if rows were involved or not, and print the appropriate message.

Parameters:
out - the place to write to
stmt - the Statement to display
conn - the Connection against which the statement was executed
Throws:
java.sql.SQLException - on JDBC access failure

indent_DisplayResults

private static void indent_DisplayResults(java.io.PrintWriter out,
                                          java.sql.Statement stmt,
                                          java.sql.Connection conn,
                                          int indentLevel)
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException

DisplayUpdateCount

static void DisplayUpdateCount(java.io.PrintWriter out,
                               int count,
                               int indentLevel)
Parameters:
out - the place to write to
count - the update count to display
indentLevel - number of tab stops to indent line

DisplayResults

public static void DisplayResults(java.io.PrintWriter out,
                                  java.sql.ResultSet rs,
                                  java.sql.Connection conn)
                           throws java.sql.SQLException
Parameters:
out - the place to write to
rs - the ResultSet to display
conn - the Connection against which the ResultSet was retrieved
Throws:
java.sql.SQLException - on JDBC access failure

indent_DisplayResults

private static void indent_DisplayResults(java.io.PrintWriter out,
                                          java.sql.ResultSet rs,
                                          java.sql.Connection conn,
                                          int indentLevel)
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException

DisplayNestedResults

private static void DisplayNestedResults(java.io.PrintWriter out,
                                         java.util.Vector nr,
                                         java.sql.Connection conn,
                                         int indentLevel)
                                  throws java.sql.SQLException
Parameters:
out - the place to write to
nr - the vector of results
conn - the Connection against which the ResultSet was retrieved
indentLevel - number of tab stops to indent line
Throws:
java.sql.SQLException - thrown on access error

DisplayNextRow

public static void DisplayNextRow(java.io.PrintWriter out,
                                  java.sql.ResultSet rs,
                                  java.sql.Connection conn)
                           throws java.sql.SQLException
Fetch the next row of the result set, and if it exists format and display a banner and the row.

Parameters:
out - the place to write to
rs - the ResultSet in use
conn - the Connection against which the ResultSet was retrieved
Throws:
java.sql.SQLException - on JDBC access failure

indent_DisplayNextRow

private static void indent_DisplayNextRow(java.io.PrintWriter out,
                                          java.sql.ResultSet rs,
                                          java.sql.Connection conn,
                                          int indentLevel)
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException

DisplayCurrentRow

public static void DisplayCurrentRow(java.io.PrintWriter out,
                                     java.sql.ResultSet rs,
                                     java.sql.Connection conn)
                              throws java.sql.SQLException
Display the current row of the result set along with a banner. Assume the result set is on a row.

Parameters:
out - the place to write to
rs - the ResultSet in use
conn - the Connection against which the ResultSet was retrieved
Throws:
java.sql.SQLException - on JDBC access failure

indent_DisplayCurrentRow

private static void indent_DisplayCurrentRow(java.io.PrintWriter out,
                                             java.sql.ResultSet rs,
                                             java.sql.Connection conn,
                                             int indentLevel)
                                      throws java.sql.SQLException
Throws:
java.sql.SQLException

DisplayBanner

public static int DisplayBanner(java.io.PrintWriter out,
                                java.sql.ResultSetMetaData rsmd)
                         throws java.sql.SQLException
Print a banner containing the column labels separated with '|'s and a line of '-'s. Each field is as wide as the display width reported by the metadata.

Parameters:
out - the place to write to
rsmd - the ResultSetMetaData to use
Throws:
java.sql.SQLException - on JDBC access failure

indent_DisplayBanner

private static int indent_DisplayBanner(java.io.PrintWriter out,
                                        java.sql.ResultSetMetaData rsmd,
                                        int indentLevel)
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

DisplayRow

private static void DisplayRow(java.io.PrintWriter out,
                               java.sql.ResultSet rs,
                               java.sql.ResultSetMetaData rsmd,
                               int rowLen,
                               java.util.Vector nestedResults,
                               java.sql.Connection conn,
                               int indentLevel)
                        throws java.sql.SQLException
Print one row of a result set, padding each field to the display width and separating them with '|'s

Parameters:
out - the place to write to
rs - the ResultSet to use
rsmd - the ResultSetMetaData to use
rowLen -
nestedResults -
conn -
indentLevel - number of tab stops to indent line
Throws:
java.sql.SQLException - thrown on JDBC access failure

checkNotNull

public static void checkNotNull(java.lang.Object o,
                                java.lang.String what)
Check if an object is null, and if it is, throw an exception with an informative parameter about what was null. The exception is a run-time exception that is internal to ij.

Parameters:
o - the object to test
what - the information to include in the error if it is null

mapNull

public static java.lang.String mapNull(java.lang.String s,
                                       java.lang.String nullValue)
Map the string to the value if it is null.

Parameters:
s - the string to test for null
nullValue - the value to use if s is null
Returns:
if s is non-null, s; else nullValue.

doTrace

public static void doTrace(java.io.PrintWriter out,
                           java.lang.Exception e)
If the property ij.exceptionTrace is true, display the stack trace to the print stream. Otherwise, do nothing.

Parameters:
out - the output stream to write to
e - the exception to display

setMaxDisplayWidth

public static void setMaxDisplayWidth(int maxDisplayWidth)

indentedPrintLine

private static void indentedPrintLine(java.io.PrintWriter out,
                                      int indentLevel,
                                      java.lang.String text)

indentedPrintLine

private static void indentedPrintLine(java.io.PrintWriter out,
                                      int indentLevel,
                                      java.lang.StringBuffer text)

indent

private static void indent(java.io.PrintWriter out,
                           int indentLevel)

ShowException

public static void ShowException(java.io.PrintStream out,
                                 java.lang.Throwable e)

ShowSQLException

public static void ShowSQLException(java.io.PrintStream out,
                                    java.sql.SQLException e)

ShowWarnings

public static void ShowWarnings(java.io.PrintStream out,
                                java.sql.Connection theConnection)

ShowWarnings

public static void ShowWarnings(java.io.PrintStream out,
                                java.sql.SQLWarning warning)

ShowWarnings

public static void ShowWarnings(java.io.PrintStream out,
                                java.sql.ResultSet rs)

ShowWarnings

public static void ShowWarnings(java.io.PrintStream out,
                                java.sql.Statement s)

DisplayResults

public static void DisplayResults(java.io.PrintStream out,
                                  java.sql.Statement stmt,
                                  java.sql.Connection conn)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

indent_DisplayResults

private static void indent_DisplayResults(java.io.PrintStream out,
                                          java.sql.Statement stmt,
                                          java.sql.Connection conn,
                                          int indentLevel)
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException

DisplayUpdateCount

static void DisplayUpdateCount(java.io.PrintStream out,
                               int count,
                               int indentLevel)

DisplayResults

public static void DisplayResults(java.io.PrintStream out,
                                  java.sql.ResultSet rs,
                                  java.sql.Connection conn)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

indent_DisplayResults

private static void indent_DisplayResults(java.io.PrintStream out,
                                          java.sql.ResultSet rs,
                                          java.sql.Connection conn,
                                          int indentLevel)
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException

DisplayNestedResults

private static void DisplayNestedResults(java.io.PrintStream out,
                                         java.util.Vector nr,
                                         java.sql.Connection conn,
                                         int indentLevel)
                                  throws java.sql.SQLException
Throws:
java.sql.SQLException

DisplayNextRow

public static void DisplayNextRow(java.io.PrintStream out,
                                  java.sql.ResultSet rs,
                                  java.sql.Connection conn)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

indent_DisplayNextRow

private static void indent_DisplayNextRow(java.io.PrintStream out,
                                          java.sql.ResultSet rs,
                                          java.sql.Connection conn,
                                          int indentLevel)
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException

DisplayCurrentRow

public static void DisplayCurrentRow(java.io.PrintStream out,
                                     java.sql.ResultSet rs,
                                     java.sql.Connection conn)
                              throws java.sql.SQLException
Throws:
java.sql.SQLException

indent_DisplayCurrentRow

private static void indent_DisplayCurrentRow(java.io.PrintStream out,
                                             java.sql.ResultSet rs,
                                             java.sql.Connection conn,
                                             int indentLevel)
                                      throws java.sql.SQLException
Throws:
java.sql.SQLException

DisplayBanner

public static int DisplayBanner(java.io.PrintStream out,
                                java.sql.ResultSetMetaData rsmd)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

indent_DisplayBanner

private static int indent_DisplayBanner(java.io.PrintStream out,
                                        java.sql.ResultSetMetaData rsmd,
                                        int indentLevel)
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

DisplayRow

private static void DisplayRow(java.io.PrintStream out,
                               java.sql.ResultSet rs,
                               java.sql.ResultSetMetaData rsmd,
                               int rowLen,
                               java.util.Vector nestedResults,
                               java.sql.Connection conn,
                               int indentLevel)
                        throws java.sql.SQLException
Throws:
java.sql.SQLException

doTrace

public static void doTrace(java.io.PrintStream out,
                           java.lang.Exception e)

indentedPrintLine

private static void indentedPrintLine(java.io.PrintStream out,
                                      int indentLevel,
                                      java.lang.String text)

indentedPrintLine

private static void indentedPrintLine(java.io.PrintStream out,
                                      int indentLevel,
                                      java.lang.StringBuffer text)

indent

private static void indent(java.io.PrintStream out,
                           int indentLevel)

Built on Tue 2006-10-10 19:23:47+0200, from revision exported

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.