Package org.apache.derby.impl.tools.ij
Class utilMain
java.lang.Object
org.apache.derby.impl.tools.ij.utilMain
This class is utilities specific to the two ij Main's.
This factoring enables sharing the functionality for
single and dual connection ij runs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
(package private) UCode_CharStream
private StatementFinder[]
(package private) ConnectionEnv[]
private int
private boolean
private boolean
private Hashtable
private final String
Value of the system property ij.execptionTrace(package private) org.apache.derby.impl.tools.ij.ij
(package private) org.apache.derby.impl.tools.ij.ijTokenManager
private boolean
(package private) LocalizedResource
private boolean
private final int
(package private) Stack
<StatementFinder> private LocalizedOutput
private final boolean
True if to display the error code when displaying a SQLException. -
Constructor Summary
ConstructorsConstructorDescriptionutilMain
(int numConnections, LocalizedOutput out) Set up the test to run with 'numConnections' connections/users.utilMain
(int numConnections, LocalizedOutput out, boolean loadSystemProperties) Set up the test to run with 'numConnections' connections/users.utilMain
(int numConnections, LocalizedOutput out, Hashtable ignoreErrors) Set up the test to run with 'numConnections' connections/users. -
Method Summary
Modifier and TypeMethodDescription(package private) ijResult
Position on the specified row of the specified ResultSet.(package private) ijResult
Position after the last row of the specified ResultSet and return NULL to the user.(package private) ijResult
beforeFirst
(ResultSet rs) Position before the first row of the specified ResultSet and return NULL to the user.private void
checkScrollableCursor
(ResultSet rs, String operation) Check that the cursor is scrollable.private void
cleanupGo
(LocalizedInput[] in) Perform cleanup after a script has been run.private void
displayResult
(LocalizedOutput out, ijResult result, Connection conn) private boolean
catch processing on failed commands.(package private) static void
doPrompt
(boolean newStatement, LocalizedOutput out, 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
stack trace dumper(package private) ijResult
Position on the first row of the specified ResultSet and return that row to the user.(package private) int
Get the current row numbervoid
go
(LocalizedInput[] in, LocalizedOutput out) run ij over the specified input, sending output to the specified output.int
goScript
(Connection conn, LocalizedInput in) Support to run a script.private void
This routine displays SQL exceptions and decides whether they are fatal or not, based on the ignoreErrors field.void
Initialize the connections from the environment.(package private) ijResult
Position on the last row of the specified ResultSet and return that row to the user.(package private) void
(package private) void
newResourceInput
(String resourceName) (package private) ijResult
Position on the previous row of the specified ResultSet and return that row to the user.(package private) ijResult
Move the cursor position by the specified amount.private int
Run the guts of the script.(package private) void
setMtUse
(boolean b) private void
-
Field Details
-
commandGrabber
-
charStream
UCode_CharStream charStream -
ijTokMgr
org.apache.derby.impl.tools.ij.ijTokenManager ijTokMgr -
ijParser
org.apache.derby.impl.tools.ij.ij ijParser -
connEnv
ConnectionEnv[] connEnv -
currCE
private int currCE -
numConnections
private final int numConnections -
fileInput
private boolean fileInput -
initialFileInput
private boolean initialFileInput -
mtUse
private boolean mtUse -
firstRun
private boolean firstRun -
out
-
ignoreErrors
-
showErrorCode
private final boolean showErrorCodeTrue if to display the error code when displaying a SQLException. -
ijExceptionTrace
Value of the system property ij.execptionTrace -
BUFFEREDFILESIZE
public static final int BUFFEREDFILESIZE- See Also:
-
oldGrabbers
Stack<StatementFinder> oldGrabbers -
langUtil
LocalizedResource langUtil
-
-
Constructor Details
-
utilMain
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.- Throws:
ijFatalException
-
utilMain
utilMain(int numConnections, LocalizedOutput out, boolean loadSystemProperties) throws ijFatalException Set up the test to run with 'numConnections' connections/users. This overload allows the choice of whether the system properties will be used or not.- Parameters:
numConnections
- The number of connections/users to test.- Throws:
ijFatalException
-
utilMain
public utilMain(int numConnections, LocalizedOutput out, 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.- Throws:
ijFatalException
-
-
Method Details
-
initFromEnvironment
public void initFromEnvironment()Initialize the connections from the environment. -
go
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 ijout
- sink for output from ij- Throws:
ijFatalException
-
goScript
Support to run a script. Performs minimal setup to set the passed in connection into the existing ij setup, ConnectionEnv.- Parameters:
conn
-in
-
-
supportIJProperties
-
runScriptGuts
private int runScriptGuts()Run the guts of the script. Split out to allow calling from the full ij and the minimal goScript.- Returns:
- The number of errors seen in the script.
-
cleanupGo
Perform cleanup after a script has been run. Close the input streams if required and shutdown derby on an exit.- Parameters:
in
-
-
displayResult
private void displayResult(LocalizedOutput out, ijResult result, Connection conn) throws SQLException - Throws:
SQLException
-
doCatch
catch processing on failed commands. This really ought to be in ij somehow, but it was easier to catch in Main. -
handleSQLException
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
stack trace dumper -
newInput
-
newResourceInput
-
doPrompt
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) -
checkScrollableCursor
Check that the cursor is scrollable.- Parameters:
rs
- the ResultSet to checkoperation
- which operation this is checked for- Throws:
ijException
- if the cursor isn't scrollableSQLException
- if a database error occurs
-
absolute
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:
SQLException
- thrown on error. (absolute() not supported pre-JDBC2.0)
-
relative
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:
SQLException
- thrown on error. (relative() not supported pre-JDBC2.0)
-
beforeFirst
Position before the first row of the specified ResultSet and return NULL to the user.- Parameters:
rs
- The specified ResultSet.- Returns:
- NULL.
- Throws:
SQLException
- thrown on error. (beforeFirst() not supported pre-JDBC2.0)
-
first
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:
SQLException
- thrown on error. (first() not supported pre-JDBC2.0)
-
afterLast
Position after the last row of the specified ResultSet and return NULL to the user.- Parameters:
rs
- The specified ResultSet.- Returns:
- NULL.
- Throws:
SQLException
- thrown on error. (afterLast() not supported pre-JDBC2.0)
-
last
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:
SQLException
- thrown on error. (last() not supported pre-JDBC2.0)
-
previous
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:
SQLException
- thrown on error. (previous() not supported pre-JDBC2.0)
-
getCurrentRowNumber
Get the current row number- Parameters:
rs
- The specified ResultSet.- Returns:
- The current row number
- Throws:
SQLException
- thrown on error. (getRow() not supported pre-JDBC2.0)
-