org.apache.derby.impl.tools.ij
Class utilMain

java.lang.Object
  extended byorg.apache.derby.impl.tools.ij.utilMain
All Implemented Interfaces:
java.security.PrivilegedAction
Direct Known Subclasses:
utilMain14

public class utilMain
extends java.lang.Object
implements java.security.PrivilegedAction

This class is utilities specific to the two ij Main's. This factoring enables sharing the functionality for single and dual connection ij runs.

Author:
jerry

Field Summary
static int BUFFEREDFILESIZE
           
(package private)  UCode_CharStream charStream
           
(package private)  StatementFinder[] commandGrabber
           
private static java.lang.Object[] CONN_ARG
           
private static java.lang.Class[] CONN_PARAM
           
private  java.util.Properties connAttributeDefaults
           
(package private)  ConnectionEnv[] connEnv
           
(package private)  int currCE
           
private  boolean fileInput
           
private  boolean firstRun
           
private  java.util.Hashtable ignoreErrors
           
(package private)  ij ijParser
           
(package private)  ijTokenManager ijTokMgr
           
private  boolean initialFileInput
           
protected  boolean isJCC
           
(package private)  LocalizedResource langUtil
           
private  boolean mtUse
           
private  int numConnections
           
(package private)  java.util.Stack oldGrabbers
           
private  LocalizedOutput out
           
 
Constructor Summary
utilMain(int numConnections, LocalizedOutput out)
          Set up the test to run with 'numConnections' connections/users.
utilMain(int numConnections, LocalizedOutput out, java.util.Hashtable ignoreErrors)
          Set up the test to run with 'numConnections' connections/users.
 
Method Summary
 ijResult absolute(java.sql.ResultSet rs, int row)
          Position on the specified row of the specified ResultSet.
 ijResult afterLast(java.sql.ResultSet rs)
          Position after the last row of the specified ResultSet and return NULL to the user.
 ijResult beforeFirst(java.sql.ResultSet rs)
          Position before the first row of the specified ResultSet and return NULL to the user.
 java.sql.Statement createStatement(java.sql.Connection conn, int scrollType, int holdType)
          Create the right kind of statement (scrolling or not) off of the specified connection.
private  void displayResult(LocalizedOutput out, ijResult result, java.sql.Connection conn)
           
private  void doCatch(java.lang.String command)
          catch processing on failed commands.
(package private) static void doPrompt(boolean newStatement, LocalizedOutput out, java.lang.String tag)
          REMIND: eventually this might be part of StatementFinder, used at each carriage return to show that it is still "live" when it is reading multi-line input.
private  void doTrace(java.lang.Throwable t)
          stack trace dumper
 ijResult first(java.sql.ResultSet rs)
          Position on the first row of the specified ResultSet and return that row to the user.
 java.util.Properties getConnAttributeDefaults()
           
 int getCurrentRowNumber(java.sql.ResultSet rs)
          Get the current row number
 int getHoldability(java.sql.Connection conn)
          Retrieves the current holdability of ResultSet objects created using this Connection object.
 utilMain getUtilMain()
          Return the right utilMain to use.
 void go(LocalizedInput[] in, LocalizedOutput out, java.util.Properties connAttributeDefaults)
          run ij over the specified input, sending output to the specified output.
 void handleSQLException(LocalizedOutput out, java.sql.SQLException e)
          This routine displays SQL exceptions and decides whether they are fatal or not, based on the ignoreErrors field.
 ijResult last(java.sql.ResultSet rs)
          Position on the last row of the specified ResultSet and return that row to the user.
(package private)  void newInput(java.lang.String fileName)
           
(package private)  void newResourceInput(java.lang.String resourceName)
           
 ijResult previous(java.sql.ResultSet rs)
          Position on the previous row of the specified ResultSet and return that row to the user.
 ijResult relative(java.sql.ResultSet rs, int row)
          Move the cursor position by the specified amount.
 java.lang.Object run()
           
 java.sql.Connection setHoldability(java.sql.Connection conn, int holdType)
          Connections by default create ResultSet objects with holdability true.
(package private)  void setMtUse(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONN_PARAM

private static java.lang.Class[] CONN_PARAM

CONN_ARG

private static java.lang.Object[] CONN_ARG

commandGrabber

StatementFinder[] commandGrabber

charStream

UCode_CharStream charStream

ijTokMgr

ijTokenManager ijTokMgr

ijParser

ij ijParser

connEnv

ConnectionEnv[] connEnv

currCE

int currCE

numConnections

private int numConnections

fileInput

private boolean fileInput

initialFileInput

private boolean initialFileInput

mtUse

private boolean mtUse

firstRun

private boolean firstRun

out

private LocalizedOutput out

connAttributeDefaults

private java.util.Properties connAttributeDefaults

ignoreErrors

private java.util.Hashtable ignoreErrors

isJCC

protected boolean isJCC

BUFFEREDFILESIZE

public static final int BUFFEREDFILESIZE
See Also:
Constant Field Values

oldGrabbers

java.util.Stack oldGrabbers

langUtil

LocalizedResource langUtil
Constructor Detail

utilMain

public utilMain(int numConnections,
                LocalizedOutput out)
         throws ijFatalException
Set up the test to run with 'numConnections' connections/users.

Parameters:
numConnections - The number of connections/users to test.

utilMain

public utilMain(int numConnections,
                LocalizedOutput out,
                java.util.Hashtable ignoreErrors)
         throws ijFatalException
Set up the test to run with 'numConnections' connections/users.

Parameters:
numConnections - The number of connections/users to test.
ignoreErrors - A list of errors to ignore. If null, all errors are printed out and nothing is fatal. If non-null, if an error is hit and it is in this list, it is silently ignore. Otherwise, an ijFatalException is thrown. ignoreErrors is used for stress tests.
Method Detail

go

public void go(LocalizedInput[] in,
               LocalizedOutput out,
               java.util.Properties connAttributeDefaults)
        throws ijFatalException
run ij over the specified input, sending output to the specified output. Any prior input and output will be lost.

Parameters:
in - source for input to ij
out - sink for output from ij
connAttributeDefaults - connection attributes from -ca ij arg
Throws:
ijFatalException

displayResult

private void displayResult(LocalizedOutput out,
                           ijResult result,
                           java.sql.Connection conn)
                    throws java.sql.SQLException
Throws:
java.sql.SQLException

doCatch

private void doCatch(java.lang.String command)
catch processing on failed commands. This really ought to be in ij somehow, but it was easier to catch in Main.


handleSQLException

public void handleSQLException(LocalizedOutput out,
                               java.sql.SQLException e)
                        throws ijFatalException
This routine displays SQL exceptions and decides whether they are fatal or not, based on the ignoreErrors field. If they are fatal, an ijFatalException is thrown. Lifted from ij/util.java:ShowSQLException

Throws:
ijFatalException

doTrace

private void doTrace(java.lang.Throwable t)
stack trace dumper


newInput

void newInput(java.lang.String fileName)

newResourceInput

void newResourceInput(java.lang.String resourceName)

doPrompt

static void doPrompt(boolean newStatement,
                     LocalizedOutput out,
                     java.lang.String tag)
REMIND: eventually this might be part of StatementFinder, used at each carriage return to show that it is still "live" when it is reading multi-line input.


setMtUse

void setMtUse(boolean b)

getUtilMain

public utilMain getUtilMain()
Return the right utilMain to use. (JDBC 1.1 or 2.0)


setHoldability

public java.sql.Connection setHoldability(java.sql.Connection conn,
                                          int holdType)
                                   throws java.sql.SQLException
Connections by default create ResultSet objects with holdability true. This method can be used to change the holdability of the connection by passing one of ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT. We implement this using reflection in jdk13 and lower

Parameters:
conn - The connection.
holdType - The new holdability for the Connection object.
Returns:
The connection object with holdability set to passed value.
Throws:
java.sql.SQLException

getHoldability

public int getHoldability(java.sql.Connection conn)
                   throws java.sql.SQLException
Retrieves the current holdability of ResultSet objects created using this Connection object. We implement this using reflection in jdk13 and lower

Returns:
The holdability, one of ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
Throws:
java.sql.SQLException

createStatement

public java.sql.Statement createStatement(java.sql.Connection conn,
                                          int scrollType,
                                          int holdType)
                                   throws java.sql.SQLException
Create the right kind of statement (scrolling or not) off of the specified connection.

Parameters:
conn - The connection.
scrollType - The scroll type of the cursor.
Returns:
The statement.
Throws:
java.sql.SQLException

absolute

public ijResult absolute(java.sql.ResultSet rs,
                         int row)
                  throws java.sql.SQLException
Position on the specified row of the specified ResultSet.

Parameters:
rs - The specified ResultSet.
row - The row # to move to. (Negative means from the end of the result set.)
Returns:
NULL.
Throws:
java.sql.SQLException - thrown on error. (absolute() not supported pre-JDBC2.0)

relative

public ijResult relative(java.sql.ResultSet rs,
                         int row)
                  throws java.sql.SQLException
Move the cursor position by the specified amount.

Parameters:
rs - The specified ResultSet.
row - The # of rows to move. (Negative means toward the beginning of the result set.)
Returns:
NULL.
Throws:
java.sql.SQLException - thrown on error. (relative() not supported pre-JDBC2.0)

beforeFirst

public ijResult beforeFirst(java.sql.ResultSet rs)
                     throws java.sql.SQLException
Position before the first row of the specified ResultSet and return NULL to the user.

Parameters:
rs - The specified ResultSet.
Returns:
NULL.
Throws:
java.sql.SQLException - thrown on error. (beforeFirst() not supported pre-JDBC2.0)

first

public ijResult first(java.sql.ResultSet rs)
               throws java.sql.SQLException
Position on the first row of the specified ResultSet and return that row to the user.

Parameters:
rs - The specified ResultSet.
Returns:
The first row of the ResultSet.
Throws:
java.sql.SQLException - thrown on error. (first() not supported pre-JDBC2.0)

afterLast

public ijResult afterLast(java.sql.ResultSet rs)
                   throws java.sql.SQLException
Position after the last row of the specified ResultSet and return NULL to the user.

Parameters:
rs - The specified ResultSet.
Returns:
NULL.
Throws:
java.sql.SQLException - thrown on error. (afterLast() not supported pre-JDBC2.0)

last

public ijResult last(java.sql.ResultSet rs)
              throws java.sql.SQLException
Position on the last row of the specified ResultSet and return that row to the user.

Parameters:
rs - The specified ResultSet.
Returns:
The last row of the ResultSet.
Throws:
java.sql.SQLException - thrown on error. (last() not supported pre-JDBC2.0)

previous

public ijResult previous(java.sql.ResultSet rs)
                  throws java.sql.SQLException
Position on the previous row of the specified ResultSet and return that row to the user.

Parameters:
rs - The specified ResultSet.
Returns:
The previous row of the ResultSet.
Throws:
java.sql.SQLException - thrown on error. (previous() not supported pre-JDBC2.0)

getCurrentRowNumber

public int getCurrentRowNumber(java.sql.ResultSet rs)
                        throws java.sql.SQLException
Get the current row number

Parameters:
rs - The specified ResultSet.
Returns:
The current row number
Throws:
java.sql.SQLException - thrown on error. (getRow() not supported pre-JDBC2.0)

getConnAttributeDefaults

public java.util.Properties getConnAttributeDefaults()

run

public final java.lang.Object run()
Specified by:
run in interface java.security.PrivilegedAction

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.