Class JDBCDisplayUtil

java.lang.Object
org.apache.derby.tools.JDBCDisplayUtil

public class JDBCDisplayUtil extends 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.

  • Field Details

    • MINWIDTH

      private static final int MINWIDTH
      See Also:
    • maxWidth

      private static int maxWidth
    • showSelectCount

      private static boolean showSelectCount
    • MAX_RETRIES

      private static final int MAX_RETRIES
      See Also:
  • Constructor Details

    • JDBCDisplayUtil

      public JDBCDisplayUtil()
  • Method Details

    • getShowSelectCount

      public static boolean getShowSelectCount()
    • setShowSelectCount

      public static void setShowSelectCount(boolean newValue)
    • ShowException

      public static void ShowException(PrintWriter out, 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(PrintWriter out, 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(PrintWriter out, 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(PrintWriter out, SQLWarning warning)
      Parameters:
      out - the place to write to
      warning - the SQLWarning
    • ShowWarnings

      public static void ShowWarnings(PrintWriter out, 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(PrintWriter out, 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(PrintWriter 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
    • indent_DisplayResults

      private static void indent_DisplayResults(PrintWriter out, Statement stmt, Connection conn, int indentLevel, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Throws:
      SQLException
    • DisplayUpdateCount

      static void DisplayUpdateCount(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
    • getColumnDisplayWidths

      private static int[] getColumnDisplayWidths(ResultSetMetaData rsmd, int[] dispColumns, boolean localizedOutput) throws SQLException
      Calculates column display widths from the default widths of the result set.
      Throws:
      SQLException
    • DisplayMultipleResults

      public static void DisplayMultipleResults(PrintWriter out, List<ResultSet> resultSets, Connection conn, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Parameters:
      out - the place to write to
      resultSets - list of ResultSets to display
      conn - the connection against which the ResultSets were retrieved
      displayColumns - column numbers to display, null if all
      displayColumnWidths - column widths, in characters, if displayColumns is specified
      Throws:
      SQLException - on JDBC access failure
    • DisplayResults

      public static void DisplayResults(PrintWriter out, ResultSet rs, Connection conn, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Parameters:
      out - the place to write to
      rs - the ResultSet to display
      conn - the connection against which the ResultSet was retrieved
      displayColumns - column numbers to display, null if all
      displayColumnWidths - column widths, in characters, if displayColumns is specified
      Throws:
      SQLException - on JDBC access failure
    • indent_DisplayResults

      private static void indent_DisplayResults(PrintWriter out, ResultSet rs, Connection conn, int indentLevel, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Throws:
      SQLException
    • indent_DisplayResults

      private static void indent_DisplayResults(PrintWriter out, List<ResultSet> resultSets, Connection conn, int indentLevel, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Throws:
      SQLException
    • DisplayNestedResults

      private static void DisplayNestedResults(PrintWriter out, Vector<ResultSet> nr, Connection conn, int indentLevel) throws 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:
      SQLException - thrown on access error
    • DisplayNextRow

      public static void DisplayNextRow(PrintWriter 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
    • indent_DisplayNextRow

      private static void indent_DisplayNextRow(PrintWriter out, ResultSet rs, Connection conn, int indentLevel, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Throws:
      SQLException
    • DisplayCurrentRow

      public static void DisplayCurrentRow(PrintWriter 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
    • indent_DisplayCurrentRow

      private static void indent_DisplayCurrentRow(PrintWriter out, ResultSet rs, Connection conn, int indentLevel, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Throws:
      SQLException
    • DisplayBanner

      public static int DisplayBanner(PrintWriter 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
    • indent_DisplayBanner

      private static int indent_DisplayBanner(PrintWriter out, ResultSetMetaData rsmd, int indentLevel, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Throws:
      SQLException
    • DisplayRow

      private static void DisplayRow(PrintWriter out, ResultSet rs, ResultSetMetaData rsmd, int rowLen, Vector<ResultSet> nestedResults, Connection conn, int indentLevel, int[] displayColumns, int[] displayColumnWidths) throws 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
      displayColumns - A list of column numbers to display
      displayColumnWidths - If displayColumns is set, the width of columns to display, in characters.
      Throws:
      SQLException - thrown on JDBC access failure
    • 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
    • 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.
    • doTrace

      public static void doTrace(PrintWriter 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
    • setMaxDisplayWidth

      public static void setMaxDisplayWidth(int maxDisplayWidth)
    • indentedPrintLine

      private static void indentedPrintLine(PrintWriter out, int indentLevel, String text)
    • indentedPrintLine

      private static void indentedPrintLine(PrintWriter out, int indentLevel, StringBuffer text)
    • indent

      private static void indent(PrintWriter out, int indentLevel)
    • ShowException

      public static void ShowException(PrintStream out, Throwable e)
    • ShowSQLException

      public static void ShowSQLException(PrintStream out, SQLException e)
    • ShowWarnings

      public static void ShowWarnings(PrintStream out, Connection theConnection)
    • ShowWarnings

      public static void ShowWarnings(PrintStream out, SQLWarning warning)
    • ShowWarnings

      public static void ShowWarnings(PrintStream out, ResultSet rs)
    • ShowWarnings

      public static void ShowWarnings(PrintStream out, Statement s)
    • DisplayResults

      public static void DisplayResults(PrintStream out, Statement stmt, Connection conn) throws SQLException
      Throws:
      SQLException
    • indent_DisplayResults

      private static void indent_DisplayResults(PrintStream out, Statement stmt, Connection conn, int indentLevel, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Throws:
      SQLException
    • DisplayUpdateCount

      static void DisplayUpdateCount(PrintStream out, int count, int indentLevel)
    • DisplayResults

      public static void DisplayResults(PrintStream out, ResultSet rs, Connection conn) throws SQLException
      Throws:
      SQLException
    • indent_DisplayResults

      private static void indent_DisplayResults(PrintStream out, ResultSet rs, Connection conn, int indentLevel, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Throws:
      SQLException
    • DisplayNestedResults

      private static void DisplayNestedResults(PrintStream out, Vector<ResultSet> nr, Connection conn, int indentLevel) throws SQLException
      Throws:
      SQLException
    • DisplayNextRow

      public static void DisplayNextRow(PrintStream out, ResultSet rs, Connection conn) throws SQLException
      Throws:
      SQLException
    • indent_DisplayNextRow

      private static void indent_DisplayNextRow(PrintStream out, ResultSet rs, Connection conn, int indentLevel, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Throws:
      SQLException
    • DisplayCurrentRow

      public static void DisplayCurrentRow(PrintStream out, ResultSet rs, Connection conn) throws SQLException
      Throws:
      SQLException
    • indent_DisplayCurrentRow

      private static void indent_DisplayCurrentRow(PrintStream out, ResultSet rs, Connection conn, int indentLevel, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Throws:
      SQLException
    • DisplayBanner

      public static int DisplayBanner(PrintStream out, ResultSetMetaData rsmd) throws SQLException
      Throws:
      SQLException
    • indent_DisplayBanner

      private static int indent_DisplayBanner(PrintStream out, ResultSetMetaData rsmd, int indentLevel, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Throws:
      SQLException
    • DisplayRow

      private static void DisplayRow(PrintStream out, ResultSet rs, ResultSetMetaData rsmd, int rowLen, Vector<ResultSet> nestedResults, Connection conn, int indentLevel, int[] displayColumns, int[] displayColumnWidths) throws SQLException
      Throws:
      SQLException
    • doTrace

      public static void doTrace(PrintStream out, Exception e)
    • indentedPrintLine

      private static void indentedPrintLine(PrintStream out, int indentLevel, String text)
    • indentedPrintLine

      private static void indentedPrintLine(PrintStream out, int indentLevel, StringBuffer text)
    • indent

      private static void indent(PrintStream out, int indentLevel)
    • getSystemBoolean

      private static boolean getSystemBoolean(String name)
      Get an ij boolean system property.
      Parameters:
      name - name of the property