-
- All Superinterfaces:
Scope
public interface ExecuteContext extends Scope
A context object forQueryexecution passed to registeredExecuteListener's.- Author:
- Lukas Eder
- See Also:
ExecuteListener
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @NotNull Query[]batchQueries()The jOOQQueryobjects that are being executed in batch mode, or empty if the query is unknown or if there was no jOOQQuery.@org.jetbrains.annotations.NotNull int[]batchRows()The number of rows that were affected by the last statement executed in batch mode.@NotNull String[]batchSQL()The generated SQL statements that are being executed in batch mode, or empty if the query is unknown or if there was no SQL statement.Connectionconnection()The connection to be used in this execute context.voidconnectionProvider(ConnectionProvider connectionProvider)Override theConnectionthat is being used for execution.@Nullable RuntimeExceptionexception()TheRuntimeExceptionbeing thrown.voidexception(RuntimeException e)Override theRuntimeExceptionbeing thrown.@Nullable Queryquery()The jOOQQuerythat is being executed ornullif the query is unknown, if it is a batch query, or if there was no jOOQQuery.@Nullable Recordrecord()The last record that was fetched from the result set, ornullif no record has been fetched.voidrecord(Record record)Calling this has no effect.@Nullable Result<?>result()The last result that was fetched from the result set, ornullif no result has been fetched.voidresult(Result<?> result)Calling this has no effect.@Nullable ResultSetresultSet()TheResultSetthat is being fetched ornullif the result set is unknown or if no result set is being fetched.voidresultSet(ResultSet resultSet)Override theResultSetthat is being fetched.@Nullable Routine<?>routine()The jOOQRoutinethat is being executed ornullif the query is unknown or if there was no jOOQRoutine.introws()The number of rows that were affected by the last statement.voidrows(int rows)Calling this has no effect.@NotNull String[]serverOutput()Any server output collected from this statement when.Settings.getFetchServerOutputSize()> 0voidserverOutput(String[] output)Any server output collected from this statement when.Settings.getFetchServerOutputSize()> 0@Nullable Stringsql()The SQL that is being executed ornullif the SQL statement is unknown or if there was no SQL statement.voidsql(String sql)Override the SQL statement that is being executed.@Nullable SQLExceptionsqlException()TheSQLExceptionthat was thrown by the database.voidsqlException(SQLException e)Override theSQLExceptionbeing thrown.@Nullable SQLWarningsqlWarning()TheSQLWarningthat was emitted by the database.voidsqlWarning(SQLWarning e)Override theSQLWarningbeing emitted.@Nullable PreparedStatementstatement()ThePreparedStatementthat is being executed ornullif the statement is unknown or if there was no statement.voidstatement(PreparedStatement statement)Override thePreparedStatementthat is being executed.intstatementExecutionCount()The number of times this particular statement has been executed.ExecuteTypetype()The type of database interaction that is being executed.
-
-
-
Method Detail
-
connection
Connection connection()
The connection to be used in this execute context.This returns a proxy to the
Configuration.connectionProvider()'s supplied connection. This proxy takes care of two things:- It takes care of properly implementing
Settings.getStatementType() - It takes care of properly returning a connection to
ConnectionProvider.release(Connection), once jOOQ can release the connection
- It takes care of properly implementing
-
type
ExecuteType type()
The type of database interaction that is being executed.- See Also:
ExecuteType
-
query
@Nullable @Nullable Query query()
The jOOQQuerythat is being executed ornullif the query is unknown, if it is a batch query, or if there was no jOOQQuery.- See Also:
routine(),batchQueries()
-
batchQueries
@NotNull @NotNull Query[] batchQueries()
The jOOQQueryobjects that are being executed in batch mode, or empty if the query is unknown or if there was no jOOQQuery.If a single
Queryis executed in non-batch mode, this will return an array of length1, containing thatQuery
-
routine
@Nullable @Nullable Routine<?> routine()
The jOOQRoutinethat is being executed ornullif the query is unknown or if there was no jOOQRoutine.- See Also:
routine()
-
sql
@Nullable @Nullable String sql()
The SQL that is being executed ornullif the SQL statement is unknown or if there was no SQL statement.
-
sql
void sql(String sql)
Override the SQL statement that is being executed.This may have no effect, if called at the wrong moment.
-
batchSQL
@NotNull @NotNull String[] batchSQL()
The generated SQL statements that are being executed in batch mode, or empty if the query is unknown or if there was no SQL statement.If a single
Queryis executed in non-batch mode, this will return an array of length1, containing thatQuery
-
connectionProvider
void connectionProvider(ConnectionProvider connectionProvider)
Override theConnectionthat is being used for execution.This may have no effect, if called at the wrong moment.
- See Also:
ExecuteListener.start(ExecuteContext)
-
statement
@Nullable @Nullable PreparedStatement statement()
ThePreparedStatementthat is being executed ornullif the statement is unknown or if there was no statement.This can be any of the following:
- A
java.sql.PreparedStatementfrom your JDBC driver when a jOOQQueryis being executed asStatementType.PREPARED_STATEMENT - A
java.sql.Statementfrom your JDBC driver wrapped in ajava.sql.PreparedStatementwhen your jOOQQueryis being executed asStatementType.STATIC_STATEMENT - A
java.sql.CallableStatementwhen you are executing a jOOQRoutine
- A
-
statement
void statement(PreparedStatement statement)
Override thePreparedStatementthat is being executed.This may have no effect, if called at the wrong moment.
-
statementExecutionCount
int statementExecutionCount()
The number of times this particular statement has been executed.Statements that are prepared by jOOQ can be executed multiple times without being closed if
Query.keepStatement(boolean)is activated.This value will increment as soon as the statement is about to be executed (at the
ExecuteListener.executeStart(ExecuteContext)event).
-
resultSet
@Nullable @Nullable ResultSet resultSet()
TheResultSetthat is being fetched ornullif the result set is unknown or if no result set is being fetched.
-
resultSet
void resultSet(ResultSet resultSet)
Override theResultSetthat is being fetched.This may have no effect, if called at the wrong moment.
-
record
@Nullable @Nullable Record record()
The last record that was fetched from the result set, ornullif no record has been fetched.
-
record
void record(Record record)
Calling this has no effect. It is used by jOOQ internally.
-
rows
int rows()
The number of rows that were affected by the last statement.This returns
-1:- if the number of affected rows is not yet available (e.g. prior to
the
ExecuteListener.executeEnd(ExecuteContext)event). - if affected rows are not applicable for the given statement
(statements that do not produce a JDBC
Statement.getUpdateCount().
- if the number of affected rows is not yet available (e.g. prior to
the
-
rows
void rows(int rows)
Calling this has no effect. It is used by jOOQ internally.
-
batchRows
@NotNull @org.jetbrains.annotations.NotNull int[] batchRows()
The number of rows that were affected by the last statement executed in batch mode.If a single
Queryis executed in non-batch mode, this will return an array of length1, containingrows()This returns
-1values if the number of affected rows is not yet available, or if affected rows are not applicable for a given statement.- Returns:
- The affected rows. This is never
null - See Also:
rows()
-
result
@Nullable @Nullable Result<?> result()
The last result that was fetched from the result set, ornullif no result has been fetched.
-
result
void result(Result<?> result)
Calling this has no effect. It is used by jOOQ internally.
-
exception
@Nullable @Nullable RuntimeException exception()
TheRuntimeExceptionbeing thrown.
-
exception
void exception(RuntimeException e)
Override theRuntimeExceptionbeing thrown.This may have no effect, if called at the wrong moment.
If
nullis being passed, jOOQ will internally translate the "unavailable" exception to an unspecifiedDataAccessException.
-
sqlException
@Nullable @Nullable SQLException sqlException()
TheSQLExceptionthat was thrown by the database.
-
sqlException
void sqlException(SQLException e)
Override theSQLExceptionbeing thrown.Any
SQLExceptionwill be wrapped by jOOQ using an uncheckedDataAccessException. To have jOOQ throw your own customRuntimeException, useexception(RuntimeException)instead. This may have no effect, if called at the wrong moment.If
nullis being passed, jOOQ will internally translate the "unavailable" exception to an unspecifiedDataAccessException.
-
sqlWarning
@Nullable @Nullable SQLWarning sqlWarning()
TheSQLWarningthat was emitted by the database.Note that fetching of warnings can be disabled using
Settings.isFetchWarnings(), in case of which this property will benull.
-
sqlWarning
void sqlWarning(SQLWarning e)
Override theSQLWarningbeing emitted.
-
serverOutput
@NotNull @NotNull String[] serverOutput()
Any server output collected from this statement when.Settings.getFetchServerOutputSize()> 0- Returns:
- The server output. This is never
null.
-
serverOutput
void serverOutput(String[] output)
Any server output collected from this statement when.Settings.getFetchServerOutputSize()> 0
-
-