|
|||||||
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()
Inner Class Summary |
Type | Class |
---|---|
static class |
ExecutionContext.OracleContext
|
Field Summary |
Type | Field |
---|---|
static int |
ADD_BATCH_COUNT
Constant returned by getUpdateCount indicating that a statement was added to the pending statement batch. |
static int |
AUTO_BATCH
Constant passed to setBatchLimit to indicate that implicit batch execution should be performed, and that the actual batch size is at the discretion of the SQLJ runtime implementation. |
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 indicating that a statement batch has been executed. |
static int |
LIMITED_BATCH
Deprecated. |
static int |
NEW_BATCH_COUNT
Constant returned by getUpdateCount indicating that a new statement batch was created. |
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 to indicate that no implicit batch execution should be performed upon reaching a certain batch size. |
Constructor Summary |
ExecutionContext()
Creates a new ExecutionContext object with default settings. |
ExecutionContext(ConnectionContext ctx)
Creates a new ExecutionContext object that reflects the execution settings of a given ConnectionContext's ExecutionContext. |
ExecutionContext(ExecutionContext ec)
Creates a new ExecutionContext object that reflects the execution settings of a given ExecutionContext. |
Method Summary |
Type | Method |
---|---|
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 execution context 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()
|
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. |
ExecutionContext.OracleContext |
getOracleContext()
|
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. |
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 context, false if batching is disabled. |
static ExecutionContext.OracleContext |
raiseNullExecCtx()
|
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 isBatching)
Enables or disbables batching for statements executed on the execution context. |
void |
setBatchLimit(int batchLimit)
Sets the maximum batch size. |
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 NEW_BATCH_COUNT
getUpdateCount()
public static final int ADD_BATCH_COUNT
getUpdateCount()
public static final int EXEC_BATCH_COUNT
public static final int UNLIMITED_BATCH
setBatchLimit(int)
,
getBatchLimit()
public static final int AUTO_BATCH
setBatchLimit(int)
,
getBatchLimit()
public static final int LIMITED_BATCH
Note: this constant is deprecated in favor of AUTO_BATCH
setBatchLimit(int)
,
getBatchLimit()
Constructor Detail |
public ExecutionContext()
public ExecutionContext(ExecutionContext ec)
public ExecutionContext(ConnectionContext ctx)
Method Detail |
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 setBatching(boolean isBatching)
public boolean isBatching()
public void setBatchLimit(int batchLimit)
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.
batchLimit
- UNLIMITED_BATCH if the maximum batch size is unlimited,
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()
public int[] getBatchUpdateCounts()
public int getFetchSize()
public void setFetchSize(int rows) throws java.sql.SQLException
rows
- the default fetch size for iterator objects generated from
this Statement object.public int getFetchDirection()
public void setFetchDirection(int direction) throws java.sql.SQLException
direction
- the initial fetch direction for scrollable iterator
objects generated from this ExecutionContext.public void cancel() throws java.sql.SQLException
executeUpdate()
,
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.releaseStatement()
,
ConnectedProfile.getStatement(int)
,
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.
RTStatement.executeUpdate()
,
registerStatement(sqlj.runtime.ConnectionContext, java.lang.Object, int)
public int[] executeBatch() throws java.sql.SQLException
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 execution context 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 will return null until another batchable statement is added.
Note that exceptions returned by this method will generally be instances of java.sql.BatchUpdateException.
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.
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:
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:
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.
registerStatement(sqlj.runtime.ConnectionContext,
java.lang.Object, int)
,
RTStatement.executeComplete()
public ExecutionContext.OracleContext getOracleContext()
public static ExecutionContext.OracleContext raiseNullExecCtx() throws java.sql.SQLException
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |