Class Hierarchy        Index

Class COM.cloudscape.util.JDBCDisplayUtil

java.lang.Object
   |
   +----COM.cloudscape.util.JDBCDisplayUtil

public class JDBCDisplayUtil
extends Object
Copyright © 1998-1999, Cloudscape, Inc. All rights reserved.

This class contains utility methods for displaying JDBC objects and results on a console/ASCII terminal.

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


Variable Index

 o showSelectCount

Method Index

 o checkNotNull(Object, String)
Check if an object is null, and if it is, throw an exception with an informative parameter about what was null.
 o DisplayBanner(PrintStream, ResultSetMetaData)
Print a banner containing the column labels separated with '|'s and a line of '-'s.
 o DisplayCurrentRow(PrintStream, ResultSet, Connection)
Display the current row of the result set along with a banner.
 o DisplayNextRow(PrintStream, ResultSet, Connection)
Fetch the next row of the result set, and if it exists format and display a banner and the row.
 o DisplayResults(PrintStream, ResultSet, Connection)
 o DisplayResults(PrintStream, Statement, Connection)
Pretty-print the results of a statement that has been executed.
 o doTrace(PrintStream, Exception)
If the property ij.exceptionTrace is true, display the stack trace to the print stream.
 o mapNull(String, String)
Map the string to the value if it is null.
 o setMaxDisplayWidth(int)
 o ShowException(PrintStream, Throwable)
Print information about the exception to the given PrintStream.
 o ShowSQLException(PrintStream, SQLException)
Print information about the SQL exception to the given PrintStream.
 o ShowWarnings(PrintStream, Connection)
Print information about the SQL warnings for the connection to the given PrintStream.
 o ShowWarnings(PrintStream, ResultSet)
Print information about the SQL warnings for the ResultSet to the given PrintStream.
 o ShowWarnings(PrintStream, SQLWarning)
 o ShowWarnings(PrintStream, Statement)
Print information about the SQL warnings for the Statement to the given PrintStream.

Variables

 o showSelectCount
 public static boolean showSelectCount

Methods

 o ShowException
 public static void ShowException(PrintStream out,
                                  Throwable e)
Print information about the exception to the given PrintStream. 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
 o ShowSQLException
 public static void ShowSQLException(PrintStream out,
                                     SQLException e)
Print information about the SQL exception to the given PrintStream. Walk the list of exceptions, if any.

Parameters:
out - the place to write to
e - the exception to display
 o ShowWarnings
 public static void ShowWarnings(PrintStream out,
                                 Connection theConnection)
Print information about the SQL warnings for the connection to the given PrintStream. Walks the list of exceptions, if any.

Parameters:
out - the place to write to
theConnection - the connection that may have warnings.
 o ShowWarnings
 public static void ShowWarnings(PrintStream out,
                                 SQLWarning warning)
Parameters:
out - the place to write to
warning - the SQLWarning
 o ShowWarnings
 public static void ShowWarnings(PrintStream out,
                                 ResultSet rs)
Print information about the SQL warnings for the ResultSet to the given PrintStream. Walk the list of exceptions, if any.

Parameters:
out - the place to write to
rs - the ResultSet that may have warnings on it
 o ShowWarnings
 public static void ShowWarnings(PrintStream out,
                                 Statement s)
Print information about the SQL warnings for the Statement to the given PrintStream. Walks the list of exceptions, if any.

Parameters:
out - the place to write to
s - the Statement that may have warnings on it
 o DisplayResults
 public static void DisplayResults(PrintStream out,
                                   Statement stmt,
                                   Connection conn) throws 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: SQLException
on JDBC access failure
 o DisplayResults
 public static void DisplayResults(PrintStream out,
                                   ResultSet rs,
                                   Connection conn) throws SQLException
Parameters:
out - the place to write to
rs - the ResultSet to display
conn - the Connection against which the ResultSet was retrieved
Throws: SQLException
on JDBC access failure
 o DisplayNextRow
 public static void DisplayNextRow(PrintStream out,
                                   ResultSet rs,
                                   Connection conn) throws 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: SQLException
on JDBC access failure
 o DisplayCurrentRow
 public static void DisplayCurrentRow(PrintStream out,
                                      ResultSet rs,
                                      Connection conn) throws 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: SQLException
on JDBC access failure
 o DisplayBanner
 public static int DisplayBanner(PrintStream out,
                                 ResultSetMetaData rsmd) throws 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: SQLException
on JDBC access failure
 o checkNotNull
 public static void checkNotNull(Object o,
                                 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
 o mapNull
 public static String mapNull(String s,
                              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.
 o doTrace
 public static void doTrace(PrintStream out,
                            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
 o setMaxDisplayWidth
 public static void setMaxDisplayWidth(int maxDisplayWidth)

  Class Hierarchy        Index