|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--sqlj.runtime.ExecutionContext
An execution context provides the context in which executable sql operations are preformed. An execution context object contains a number of operations for execution control, execution status, and execution cancellation. Execution control operations modify the semantics of subsequent sql operations executed on this context. Execution status operations describe the results of the last sql operation executed on this context. Execution cancellation methods terminate the currently executing sql operation on this context.
Note that concurrently executing sql operations are expected to use distinct execution contexts. The execution context implementation is not expected to support multiple sql operations executing using the same execution context object. The client is responsible for insuring the proper creation of distinct execution context instance where needed, or synchronizing the execution of operations on a particular execution context. It is also assumed that generated calls to methods on this class appear within a schronized block to avoid concurrent calls. Re-entrant SQL execution calls on the same connection context instance are supported.
ConnectionContext.getExecutionContext()| Field Summary | |
static int |
ADD_BATCH_COUNT
Constant returned by getUpdateCount() if the last statement
encountered was added to the existing statement batch rather than being
executed. |
static int |
AUTO_BATCH
Constant passed to setBatchLimit() or returned by
getBatchLimit(), indicating that implicit batch execution
should be performed, and that the actual batch size is at the discretion
of the Open SQL / SQLJ runtime. |
static int |
EXCEPTION_COUNT
Constant returned by getUpdateCount indicating that an exeception was thrown before the last execution was successfully completed, or no operation has yet been attempted on this context. |
static int |
EXEC_BATCH_COUNT
Constant returned by getUpdateCount() if the last execution was a statement batch execution. |
static int |
NEW_BATCH_COUNT
Constant returned by getUpdateCount() if the last statement
encountered was added to a new statement batch rather than being
executed. |
static int |
QUERY_COUNT
Constant returned by getUpdateCount indicating that the last execution produced a result set or iterator. |
static int |
UNLIMITED_BATCH
Constant passed to setBatchLimit() or returned by
getBatchLimit(), indicating that no implicit batch execution
should be performed once a certain batch size is reached. |
| Constructor Summary | |
ExecutionContext()
|
|
| Method Summary | |
void |
cancel()
The cancel method can be used by one thread to cancel a sql operation that is currently being executed by another thread using this context. |
boolean |
execute()
Performs a generic execute on the currently registered statement. |
int[] |
executeBatch()
Executes the pending statement batch contained in this ExecutionContext object and returns the result as an array
of update counts. |
sqlj.runtime.profile.RTResultSet |
executeQuery()
Performs an execute query on the currently registered statement. |
int |
executeUpdate()
Performs an execute update on the currently registered statement. |
int |
getBatchLimit()
Returns the current batch limit that was set for this BatchExecutionContext object.
|
int[] |
getBatchUpdateCounts()
Returns an array of update counts containing one element for each command in the last statement batch to successfully complete execution. |
int |
getFetchDirection()
Retrieves the direction for fetching rows from database tables that is the default for scrollable iterator objects generated from this ExecutionContext object. |
int |
getFetchSize()
Retrieves the number of rows that is the current fetch size for iterator objects generated from this ExecutionContext object. |
int |
getMaxFieldSize()
The max field size limit (in bytes) is the maximum amount of data returned for any column value for sql operations subsequently executed using this context; it only applies to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR columns. |
int |
getMaxRows()
The max rows limit is the maximum number of rows that any ResultSetIterator or jdbc ResultSet returned by sql operations subsequently executed using this context can contain. |
java.sql.ResultSet |
getNextResultSet()
Moves to the currently registered statement's next result. |
int |
getQueryTimeout()
The query timeout limit is the maxiumum number of seconds sql opeations subsequently executed using this context may take to complete. |
int |
getUpdateCount()
Returns the number of rows updated by the last sql operation to complete execution using this context. 0 is returned if the last sql operation was not a DML statement. |
java.sql.SQLWarning |
getWarnings()
Returns the first warning reported by the last sql operation to complete execution using this context. |
boolean |
isBatching()
Returns true if batching is currently enabled for this
execution contextobject, false if batching is disabled.
|
sqlj.runtime.profile.RTStatement |
registerStatement(ConnectionContext connCtx,
java.lang.Object profileKey,
int stmtNdx)
Creates, registers and returns a statement. |
void |
releaseStatement()
Releases the currently registered statement, signaling that all execution-related operations have completed. |
void |
setBatching(boolean doBatch)
Enables or disables batching for statements executed on this ExecutionContext object. |
void |
setBatchLimit(int batchLimit)
Sets the maximum batch size on this batch context object. |
void |
setFetchDirection(int direction)
Gives the SQLJ runtime a hint as to the direction in which rows of scrollable iterator objects are processed. |
void |
setFetchSize(int rows)
Gives the SQLJ runtime a hint as to the number of rows that should be fetched when more rows are needed. |
void |
setMaxFieldSize(int max)
The max field size limit (in bytes) is the maximum amount of data returned for any column value for sql operations subsequently executed using this context; it only applies to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR columns. |
void |
setMaxRows(int max)
The max rows limit is the maximum number of rows that any ResultSetIterator or jdbc ResultSet returned by sql operations subsequently executed using this context can contain. |
void |
setQueryTimeout(int seconds)
The query timeout limit is the maxiumum number of seconds sql opeations subsequently executed using this context may take to complete. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int QUERY_COUNT
getUpdateCount()public static final int EXCEPTION_COUNT
getUpdateCount()public static final int ADD_BATCH_COUNT
getUpdateCount() if the last statement
encountered was added to the existing statement batch rather than being
executed.public static final int EXEC_BATCH_COUNT
public static final int NEW_BATCH_COUNT
getUpdateCount() if the last statement
encountered was added to a new statement batch rather than being
executed.public static final int UNLIMITED_BATCH
setBatchLimit() or returned by
getBatchLimit(), indicating that no implicit batch execution
should be performed once a certain batch size is reached.public static final int AUTO_BATCH
setBatchLimit() or returned by
getBatchLimit(), indicating that implicit batch execution
should be performed, and that the actual batch size is at the discretion
of the Open SQL / SQLJ runtime.| Constructor Detail |
public ExecutionContext()
| Method Detail |
public int getFetchDirection()
throws java.sql.SQLException
Note: Open SQL / SQLJ supports onyl FETCH_FORWARD.
java.sql.SQLException - - if a database access error occurs.
public int getFetchSize()
throws java.sql.SQLException
java.sql.SQLException - - if a database access error occurs.
public void setFetchSize(int rows)
throws java.sql.SQLException
rows - - the default fetch size for iterator objects generated from this Statement object.java.sql.SQLException - - if rows < 0 or rows > maxRows
public void setFetchDirection(int direction)
throws java.sql.SQLException
Note: Open SQL / SQLJ supports onyl FETCH_FORWARD.
direction - - the initial fetch direction for scrollable iterator
objects generated from this ExecutionContext.java.sql.SQLException - - if the given direction is not one
of ResultSetIterator.FETCH_FORWARD, ResultSetIterator.FETCH_REVERSE,
or ResultSetIterator.FETCH_UNKNOWN.public void setBatching(boolean doBatch)
ExecutionContext object. When batching is enabled, batchable
statements that are registered with this execution context object will be
added to a statement batch for deferred execution instead of being
executed immediately. A statement batch can be executed explicitly using
the executeBatch() command. Statement batches are also
executed implicitly when a statement that cannot be added to the current
statement batch is executed. If a statement being executed is batchable
and compatible with the current statement batch, it is added to the
batch.
When batching is disabled, statements are executed as usual. Subsequent statements are not considered for addition to the pending statement batch. This method only affects statements encountered after it is called. It does not affect statements that have previously been or are currently being executed, nor does it affect the pending statement batch.
Note: Batching is not supported in Open SQL / SQLJ for statements
executed using the sqlj.runtime.ExecutionContext. To use
batching, statements have to be executed via the
com.sap.sql.BatchExecutionContext.
doBatch - true if batching should be enabled;
false if batching should be disabledBatchExecutionContextpublic boolean isBatching()
true if batching is currently enabled for this
execution contextobject, false if batching is disabled.
Note that the value returned reflects only whether it is possible to
batch statements, but not whether a pending statement batch exists.
Note: Batching is not supported in Open SQL / SQLJ for statements
executed using the sqlj.runtime.ExecutionContext. To use
batching, statements have to be executed via the
com.sap.sql.BatchExecutionContext.
true; otherwise,
false.UNLIMITED_BATCH,
AUTO_BATCHpublic void setBatchLimit(int batchLimit)
ExecutionContext.UNLIMITED_BATCH is
specified, the maximum batch size is unlimited, and can not be exceeded.
New BatchExecutionContext objects are always created with
UNLIMITED_BATCH.
batchLimit is specified, an
implict batch execution will be performed, whenever the number of batched
statements reaches batchLimit.
ExecutionContext.AUTO_BATCH is
specified, the maximum batch size is finite but unspecified.
Note: Batching is not supported in Open SQL / SQLJ for statements
executed using the sqlj.runtime.ExecutionContext. To use
batching, statements have to be executed via the
com.sap.sql.BatchExecutionContext.
batchLimit - ExecutionContext.UNLIMITED_BATCH if the
maximum batch size is unlimited,
ExecutionContext.AUTO_BATCH if the maximum batch size is
finite and implementation dependent, or n > 0 for a maximum
batch size of n.public int getBatchLimit()
BatchExecutionContext object.
Note: Batching is not supported in Open SQL / SQLJ for statements
executed using the sqlj.runtime.ExecutionContext. To use
batching, statements have to be executed via the
com.sap.sql.BatchExecutionContext.
ExecutionContext.UNLIMITED_BATCH.
ExecutionContext.AUTO_BATCH.
n > 0.
UNLIMITED_BATCH,
AUTO_BATCH
public int[] executeBatch()
throws java.sql.SQLException
ExecutionContext object and returns the result as an array
of update counts. If no pending statement batch exists for this
ExecutionContext object, null is returned.
Upon direct or exceptional return from this method, update count is set
to EXEC_BATCH_COUNT. If this method returns successfully,
the batch update counts of this ExecutionContext object are
updated to reflect the return result.
Once this method is called, the statement batch is emptied even if the
call results in an exception. If a new statement batch is created as a
result of executing the current batch, the new batch is implicitly
executed. Subsequent calls to this method return null until
another batchable statement is added.
Notes:
java.sql.BatchUpdateException.
sqlj.runtime.ExecutionContext. To use
batching, statements have to be executed via the
com.sap.sql.BatchExecutionContext.
null; otherwise,
an array of update counts containing one element for each command in the
batch. The array is ordered according to the order in which commands were
inserted into the batch. Each element either contains a non-negative
update count, or the value -2 as a generic success
indicator, or the value -3 as a generic failure indicator.
Failure may also be indicated by an array that has fewer elements than
the number of commands in the batch. In this case, each element must
contain either a non-negative update count or the value -2
as a generic success indicator.java.sql.SQLException - if a database access error occurs while executing the statement batch.EXEC_BATCH_COUNT,
BatchUpdateExceptionpublic int[] getBatchUpdateCounts()
null if no statement batch has completed execution.
Note: Batching is not supported in Open SQL / SQLJ for statements
executed using the sqlj.runtime.ExecutionContext. To use
batching, statements have to be executed via the
com.sap.sql.BatchExecutionContext.
null; otherwise, an array of update counts resulting from
the last statement batch executed.
The array is ordered according to the order in which commands were
inserted into the batch. Each element either contains a non-negative
update count, or the value -2 as a generic success
indicator, or the value -3 elements than the number of
commands in the batch. In this case, each element must contain either a
non-negative update count or the value -2 2 as a generic
success indicator.
public int getMaxFieldSize()
By default, the max field size limit is zero (unlimited)
public void setMaxFieldSize(int max)
By default, the max field size limit is zero (unlimited)
Note: max field size is an optional feature that may not be supported by some implementations. Setting max field size to a non-default value may cause an SQLException to be raised when an SQL operation is executed using this context.
max - the new max field size limit; zero means unlimitedpublic int getMaxRows()
By default, the max rows limit is zero (unlimited)
public void setMaxRows(int max)
By default, the max rows limit is zero (unlimited)
Note: max rows is an optional feature that may not be supported by some implementations. Setting max rows to a non-default value may cause an SQLException to be raised when an SQL operation is executed using this context.
max - the new max rows limit; zero means unlimitedpublic int getQueryTimeout()
By default, the query timeout limit is zero (unlimited)
public void setQueryTimeout(int seconds)
By default, the query timeout limit is zero (unlimited)
Note: query timeout is an optional feature that may not be supported by some implementations. Setting query timeout to a non-default value may cause an SQLException to be raised when an SQL operation is executed using this context.
seconds - the new query timeout limit in seconds; zero means
unlimitedpublic java.sql.SQLWarning getWarnings()
Note: If you are processing an iterator, then any warnings associated with iterator column reads will be chained on the iterator object.
public int getUpdateCount()
public void cancel()
throws java.sql.SQLException
java.sql.SQLException - if unable to cancelexecuteUpdate(),
executeQuery()
public sqlj.runtime.profile.RTStatement registerStatement(ConnectionContext connCtx,
java.lang.Object profileKey,
int stmtNdx)
throws java.sql.SQLException
The statement is created by accessing the connected profile within
connection context "connCtx" that has the key "profileKey". The
statement at index "stmtNdx" in the connected profile is created using
the getStatement method.
The statement created is registered and becomes the current statement of this execution context.
For each of the max rows, max field size, and query timeout attributes of this execution context, if the attribute has a non-default value, then the corresponding attribute of the registered statement is set to this value. An exception is raised if the statement does not support setting the attribute. The attributes of the execution context contained by the passed connection context are not used by this method. Note that if this method throws an exception, no statement will be registered.
Note: It is assumed that this method is called within a block that is synchronized on this execution context instance. Subsequent calls to execute and release the statement returned should also appear within the same synchronized block. If there is another statement currently registered on this execution context, it is assumed that this method is a recursive callin initiated by the currently registered statement. In such cases, state involving the currently registered statement is saved, and the statement returned by this method becomes the currently registered statement. Once this new statement completes execution and is released, the previous statement is restored as the currently registered statement.
connCtx - the connection context that contains the profile that
contains the statement to register.profileKey - the key of the connected profile within the
connection context.stmtNdx - the 0-based index of the statement within the profile
to be registered.java.sql.SQLException - if the max fields size, max rows, or query timeout cannot be set on
the registered statement.releaseStatement(),
ConnectedProfile.getStatement(int, java.util.Map),
ConnectionContext.getConnectedProfile(java.lang.Object)
public int executeUpdate()
throws java.sql.SQLException
This method is called by generated code. Most programmers will not need to call it directly.
Note: It is assumed that this method is called within a block that is synchronized on this execution context instance. Furthermore, it is also assumed that the previous call to register and the subsequent call to release the current statement also appear within the same synchronized block.
java.sql.SQLException - if an error occurs during the execution of the
currently registered statement.RTStatement.executeUpdate(),
registerStatement(sqlj.runtime.ConnectionContext, java.lang.Object, int)
public sqlj.runtime.profile.RTResultSet executeQuery()
throws java.sql.SQLException
This method is called by generated code. Most programmers will not need to call it directly.
Note: It is assumed that this method is called within a block that is synchronized on this execution context instance. Furthermore, it is also assumed that the previous call to register and the subsequent call to release the current statement also appear within the same synchronized block.
java.sql.SQLException - if an error occurs during the execution of the
currently registered statement.RTStatement.executeRTQuery(),
registerStatement(sqlj.runtime.ConnectionContext, java.lang.Object, int)
public boolean execute()
throws java.sql.SQLException
The "execute" method executes the currently registered statement and returns true if it produced a side-channel result set, false otherwise. The getNextResultSet method is used to obtain the result set. When the statement is released, the update count will be set to QUERY_COUNT.
Notes:
java.sql.SQLException - if an error occurs during the execution of the currently registered
statement.RTStatement.execute(),
registerStatement(sqlj.runtime.ConnectionContext, java.lang.Object, int),
getNextResultSet()
public java.sql.ResultSet getNextResultSet()
throws java.sql.SQLException
getNextResultSet returns null when there are no further results. null is also returned if the last SQL operation executed did not produce side-channel results, or an SQL operation has not yet been executed on this execution context.
Notes:
java.sql.SQLException - if an error occurs obtaining the next result set.RTStatement.getResultSet(),
RTStatement.getMoreResults(),
execute(),
registerStatement(sqlj.runtime.ConnectionContext, java.lang.Object, int)
public void releaseStatement()
throws java.sql.SQLException
This method calls the executeComplete method of the
registered statement.
If the execution of the currently registered statement produced multiple results and not all results have been processed, then this operation is a no-op. In such cases, this method will be automatically called to release the statement once all results have been processed and getNextResultSet returns null.
This method is called by generated code. Most programmers will not need to call it directly.
Note: It is assumed that this method is called within a block that is synchronized on this execution context instance. Furthermore, it is also assumed that the previous calls to register and execute the current statement also appeared within the same synchronized block.
java.sql.SQLException - if an error occurs retrieving the warningsregisterStatement(sqlj.runtime.ConnectionContext, java.lang.Object, int),
RTStatement.executeComplete()
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||