-
- All Superinterfaces:
EventListener,Serializable
- All Known Implementing Classes:
CallbackExecuteListener,DefaultExecuteListener,LoggerListener,StopWatchListener
public interface ExecuteListener extends EventListener, Serializable
An event listener forQuery,Routine, orResultSetrender, prepare, bind, execute, fetch steps.ExecuteListeneris a base type for loggers, debuggers, profilers, data collectors that can be hooked into a jOOQDSLContextusing theConfiguration.executeListenerProviders()property, passingSettingstoDSL.using(java.sql.Connection, SQLDialect, Settings). jOOQ will use that configuration at the beginning of a query execution event to instantiate all the provided listeners. In other words, listeners have the same lifetime as a single query execution, and can thus be used to store state between the moment when a query execution starts, and the moment when a query execution finishes. AdvancedExecuteListenerscan also provide custom implementations ofConnection,PreparedStatement,ResultSet,SQLExceptionorRuntimeExceptionto jOOQ in appropriate methods.For convenience, consider extending
DefaultExecuteListenerinstead of implementing this interface. This will prevent compilation errors in future versions of jOOQ, when this interface might get new methods.The following table explains how every type of statement / operation invokes callback methods in the correct order for all registered
ExecuteListeners. Find a legend below the table for the various use cases.Callback method Use case [1] Use case [2] Use case [3] Use case [4] Use case [5] Use case [6] start(ExecuteContext)Yes, 1x Yes, 1x Yes, 1x Yes, 1x Yes, 1x Yes, 1x renderStart(ExecuteContext)Yes, 1x Yes, 1x No Yes, 1x Yes, Nx (for every query) Yes, 1x renderEnd(ExecuteContext)Yes, 1x Yes, 1x No Yes, 1x Yes, Nx (for every query) Yes, 1x prepareStart(ExecuteContext)Yes, 1x Yes, 1x No Yes, 1x Yes, Nx (for every query) Yes, 1x prepareEnd(ExecuteContext)Yes, 1x Yes, 1x No Yes, 1x Yes, Nx (for every query) Yes, 1x bindStart(ExecuteContext)Yes, 1x No No Yes, Nx (for every value set) No Yes, 1x bindEnd(ExecuteContext)Yes, 1x No No Yes, Nx (for every value set) No Yes, 1 executeStart(ExecuteContext)Yes, 1x Yes, 1x No Yes, 1x Yes, 1x Yes, 1x executeEnd(ExecuteContext)Yes, 1x Yes, 1x No Yes, 1x Yes, 1x Yes, 1x outStart(ExecuteContext)No No No No No Yes, 1x outEnd(ExecuteContext)No No No No No Yes, 1x fetchStart(ExecuteContext)Yes, 1x (Nx for ResultQuery.fetchMany()Yes, 1x (Nx for ResultQuery.fetchMany()Yes, 1x No No No resultStart(ExecuteContext)Yes, 1x (Nx for Cursor.fetchNext(int)Yes, 1x (Nx for Cursor.fetchNext(int)Yes, 1x No No No recordStart(ExecuteContext)
Yes, Nx Yes, Nx Yes, Nx No No No recordEnd(ExecuteContext)Yes, Nx Yes, Nx Yes, Nx No No No resultEnd(ExecuteContext)Yes, 1x (Nx for Cursor.fetchNext(int)Yes, 1x (Nx for Cursor.fetchNext(int)Yes, 1x No No No fetchEnd(ExecuteContext)Yes, 1x (Nx for ResultQuery.fetchMany()Yes, 1x (Nx for ResultQuery.fetchMany()Yes, 1x No No No end(ExecuteContext)Yes, 1x Yes, 1x Yes, 1x Yes, 1x Yes, 1x Yes, 1x warning(ExecuteContext)Maybe, 1x Maybe, 1x Maybe, 1x Maybe, 1x Maybe, 1x Maybe, 1x exception(ExecuteContext)Maybe, 1x Maybe, 1x Maybe, 1x Maybe, 1x Maybe, 1x Maybe, 1x
Legend:
- Used with
ResultQueryof statement typeStatementType.PREPARED_STATEMENT - Used with
ResultQueryof statement typeStatementType.STATIC_STATEMENT - Used with
DSLContext.fetch(ResultSet)or withInsertResultStep.fetch() - Used with
DSLContext.batch(Query) - Used with
DSLContext.batch(Query[]) - Used with
DSLContext.batch(Queries) - Used with a
Routinestandalone call
If nothing is specified, the default is to use
LoggerListeneras the only event listener, as configured inSettings.isExecuteLogging()- Author:
- Lukas Eder
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidbindEnd(ExecuteContext ctx)Called after bind variables to thePreparedStatement.voidbindStart(ExecuteContext ctx)Called before bind variables to thePreparedStatement.voidend(ExecuteContext ctx)Called at the end of the execution lifecycle.voidexception(ExecuteContext ctx)Called in the event of an exception at any moment of the execution lifecycle.voidexecuteEnd(ExecuteContext ctx)Called after executing a statement.voidexecuteStart(ExecuteContext ctx)Called before executing a statement.voidfetchEnd(ExecuteContext ctx)Called after fetching data from aResultSet.voidfetchStart(ExecuteContext ctx)Called before fetching data from aResultSet.voidoutEnd(ExecuteContext ctx)Called after fetching out parameter values from aCallableStatement.voidoutStart(ExecuteContext ctx)Called before fetching out parameter values from aCallableStatement.voidprepareEnd(ExecuteContext ctx)Called after preparing / creating the SQL statement.voidprepareStart(ExecuteContext ctx)Called before preparing / creating the SQL statement.voidrecordEnd(ExecuteContext ctx)Called after fetching a record from aResultSet.voidrecordStart(ExecuteContext ctx)Called before fetching a record from aResultSet.voidrenderEnd(ExecuteContext ctx)Called after rendering SQL from aQueryPart.voidrenderStart(ExecuteContext ctx)Called before rendering SQL from aQueryPart.voidresultEnd(ExecuteContext ctx)Called after fetching a set of records from aResultSet.voidresultStart(ExecuteContext ctx)Called before fetching a set of records from aResultSet.voidstart(ExecuteContext ctx)Called to initialise anExecuteListener.voidwarning(ExecuteContext ctx)Called in the event of a warning at any moment of the execution lifecycle.
-
-
-
Method Detail
-
start
void start(ExecuteContext ctx)
Called to initialise anExecuteListener.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwise
ExecuteContext:ExecuteContext.connectionProvider(ConnectionProvider): The connection provider used for execution. This may be particularly interesting if aQuerywas de-serialised and is thus lacking the underlying connection
-
renderStart
void renderStart(ExecuteContext ctx)
Called before rendering SQL from aQueryPart.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwise
-
renderEnd
void renderEnd(ExecuteContext ctx)
Called after rendering SQL from aQueryPart.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..
Overridable attributes in
ExecuteContext:ExecuteContext.sql(String): The renderedSQLstatement that is about to be executed. You can modify this statement freely.
-
prepareStart
void prepareStart(ExecuteContext ctx)
Called before preparing / creating the SQL statement.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..
Overridable attributes in
ExecuteContext:ExecuteContext.sql(String): The renderedSQLstatement that is about to be executed. You can modify this statement freely.ExecuteContext.statement(): ThePreparedStatementabout to be executed. At this stage, no such statement is available yet, but if provided, the execution lifecycle will skip preparing a statement. This can be used e.g. to implement a transaction-bound prepared statement cache.A custom
PreparedStatementneeds to take into accountSettings.getStatementType(), and avoid bind variable markers forStatementType.STATIC_STATEMENT.Flags such as
Query.queryTimeout(int),Query.poolable(boolean),ResultQuery.maxRows(int), which correspond to mutable flags on aPreparedStatement, are set by jOOQ even if a listener provides the statement.Flags such as
ResultQuery.resultSetConcurrency(int),ResultQuery.resultSetHoldability(int),ResultQuery.resultSetType(int), which correspond to immutable flags that are set on the statement at statement creation are not set on a statement provided by a listener.
-
prepareEnd
void prepareEnd(ExecuteContext ctx)
Called after preparing / creating the SQL statement.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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
Overridable attributes in
ExecuteContext:ExecuteContext.statement(PreparedStatement): TheStatement,PreparedStatement, orCallableStatementthat is about to be executed. You can modify this statement freely, or wrapExecuteContext.statement()with your enriched statement wrapper
-
bindStart
void bindStart(ExecuteContext ctx)
Called before bind variables to thePreparedStatement.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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.CallableStatementwhen you are executing a jOOQRoutine
- A
Overridable attributes in
ExecuteContext:ExecuteContext.statement(PreparedStatement): ThePreparedStatement, orCallableStatementthat is about to be executed. You can modify this statement freely, or wrapExecuteContext.statement()with your enriched statement wrapper
Note that this method is not called when executing queries of type
StatementType.STATIC_STATEMENT
-
bindEnd
void bindEnd(ExecuteContext ctx)
Called after bind variables to thePreparedStatement.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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.CallableStatementwhen you are executing a jOOQRoutine
- A
Overridable attributes in
ExecuteContext:ExecuteContext.statement(PreparedStatement): TheStatement,PreparedStatement, orCallableStatementthat is about to be executed. You can modify this statement freely, or wrapExecuteContext.statement()with your enriched statement wrapper
Note that this method is not called when executing queries of type
StatementType.STATIC_STATEMENT
-
executeStart
void executeStart(ExecuteContext ctx)
Called before executing a statement.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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
Overridable attributes in
ExecuteContext:ExecuteContext.statement(PreparedStatement): TheStatement,PreparedStatement, orCallableStatementthat is about to be executed. You can modify this statement freely, or wrapExecuteContext.statement()with your enriched statement wrapper
Other attributes in
ExecuteContext, affected by this lifecycle phase:ExecuteContext.statementExecutionCount()is incremented.
-
executeEnd
void executeEnd(ExecuteContext ctx)
Called after executing a statement.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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
ExecuteContext.resultSet(): TheResultSetthat is about to be fetched ornull, if theQueryreturns no result set, or if aRoutineis being executed.ExecuteContext.rows(): The number of affected rows if applicable. In case aResultSetis fetched, this number is only available at thefetchEnd(ExecuteContext)event.ExecuteContext.serverOutput(): The server output if available. This may be fetched whenSettings.getFetchServerOutputSize()> 0
Overridable attributes in
ExecuteContext:ExecuteContext.resultSet(ResultSet): TheResultSetthat is about to be fetched. You can modify this result set freely, or wrapExecuteContext.resultSet()with your enriched result set wrapper
-
outStart
void outStart(ExecuteContext ctx)
Called before fetching out parameter values from aCallableStatement.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. This can be any of the following:
- A
java.sql.CallableStatementwhen you are executing a jOOQRoutine
- A
ExecuteContext.sqlWarning(): TheSQLWarningthat was emitted by the database ornullif no warning was emitted.
Note that this method is called only when executing standalone routine calls.
-
outEnd
void outEnd(ExecuteContext ctx)
Called after fetching out parameter values from aCallableStatement.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. This can be any of the following:
- A
java.sql.CallableStatementwhen you are executing a jOOQRoutine
- A
ExecuteContext.sqlWarning(): TheSQLWarningthat was emitted by the database ornullif no warning was emitted.
Note that this method is called only when executing standalone routine calls.
-
fetchStart
void fetchStart(ExecuteContext ctx)
Called before fetching data from aResultSet.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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
ExecuteContext.resultSet(): TheResultSetthat is about to be fetched.ExecuteContext.sqlWarning(): TheSQLWarningthat was emitted by the database ornullif no warning was emitted.
Overridable attributes in
ExecuteContext:ExecuteContext.resultSet(ResultSet): TheResultSetthat is about to be fetched. You can modify this result set freely, or wrapExecuteContext.resultSet()with your enriched result set wrapper
In case of multiple
ResultSetswithResultQuery.fetchMany(), this is called several times, once perResultSetNote that this method is not called when executing queries that do not return a result, or when executing routines.
-
resultStart
void resultStart(ExecuteContext ctx)
Called before fetching a set of records from aResultSet.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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
ExecuteContext.resultSet(): TheResultSetthat is about to be fetched.ExecuteContext.result(): The set of records that are about to be fetched.ExecuteContext.sqlWarning(): TheSQLWarningthat was emitted by the database ornullif no warning was emitted.
Note that this method is not called when executing queries that do not return a result, or when executing routines. This is also not called when fetching single records, with
Cursor.fetchNext()for instance.
-
recordStart
void recordStart(ExecuteContext ctx)
Called before fetching a record from aResultSet.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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
ExecuteContext.resultSet(): TheResultSetthat is about to be fetched.ExecuteContext.record(): TheRecordthat is about to be fetched.ExecuteContext.sqlWarning(): TheSQLWarningthat was emitted by the database ornullif no warning was emitted.
Note that this method is not called when executing queries that do not return a result, or when executing routines.
-
recordEnd
void recordEnd(ExecuteContext ctx)
Called after fetching a record from aResultSet.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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
ExecuteContext.resultSet(): TheResultSetthat is about to be fetched.ExecuteContext.record(): The lastRecordthat was fetched.ExecuteContext.sqlWarning(): TheSQLWarningthat was emitted by the database ornullif no warning was emitted.
Note that this method is not called when executing queries that do not return a result, or when executing routines.
-
resultEnd
void resultEnd(ExecuteContext ctx)
Called after fetching a set of records from aResultSet.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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
ExecuteContext.resultSet(): TheResultSetthat is about to be fetched.ExecuteContext.record(): The lastRecordthat was fetched.ExecuteContext.result(): The set of records that were fetched.ExecuteContext.sqlWarning(): TheSQLWarningthat was emitted by the database ornullif no warning was emitted.
Note that this method is not called when executing queries that do not return a result, or when executing routines. This is also not called when fetching single records, with
Cursor.fetchNext()for instance.
-
fetchEnd
void fetchEnd(ExecuteContext ctx)
Called after fetching data from aResultSet.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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
Statementis already closed!- A
ExecuteContext.resultSet(): TheResultSetthat was fetched. Note that theResultSetis already closed!ExecuteContext.rows(): The number of affected rows if applicable.ExecuteContext.serverOutput(): The server output if available. This may be fetched whenSettings.getFetchServerOutputSize()> 0ExecuteContext.record(): The lastRecordthat was fetched.ExecuteContext.result(): The last set of records that were fetched.ExecuteContext.sqlWarning(): TheSQLWarningthat was emitted by the database ornullif no warning was emitted.
In case of multiple
ResultSetswithResultQuery.fetchMany(), this is called several times, once perResultSetNote that this method is not called when executing queries that do not return a result, or when executing routines.
-
end
void end(ExecuteContext ctx)
Called at the end of the execution lifecycle.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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
Statementis already closed!- A
ExecuteContext.resultSet(): TheResultSetthat was fetched ornull, if no result set was fetched. Note that theResultSetmay already be closed!ExecuteContext.rows(): The number of affected rows if applicable.ExecuteContext.serverOutput(): The server output if available. This may be fetched whenSettings.getFetchServerOutputSize()> 0ExecuteContext.record(): The lastRecordthat was fetched or null if no records were fetched.ExecuteContext.result(): The last set of records that were fetched or null if no records were fetched.ExecuteContext.sqlWarning(): TheSQLWarningthat was emitted by the database ornullif no warning was emitted.
-
exception
void exception(ExecuteContext ctx)
Called in the event of an exception at any moment of the execution lifecycle.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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
Statementmay be closed!- A
ExecuteContext.resultSet(): TheResultSetthat was fetched ornull, if no result set was fetched. Note that theResultSetmay already be closed!ExecuteContext.rows(): The number of affected rows if applicable.ExecuteContext.serverOutput(): The server output if available. This may be fetched whenSettings.getFetchServerOutputSize()> 0ExecuteContext.record(): The lastRecordthat was fetched or null if no records were fetched.ExecuteContext.result(): The last set of records that were fetched or null if no records were fetched.ExecuteContext.exception(): TheRuntimeExceptionthat is about to be thrownExecuteContext.sqlException(): TheSQLExceptionthat was thrown by the database
-
warning
void warning(ExecuteContext ctx)
Called in the event of a warning at any moment of the execution lifecycle.Available attributes from
ExecuteContext:ExecuteContext.connection(): The connection used for executionScope.configuration(): The execution configurationExecuteContext.query(): TheQueryobject, if a jOOQ query is being executed ornullotherwiseExecuteContext.routine(): TheRoutineobject, if a jOOQ routine is being executed ornullotherwiseExecuteContext.sql(): The renderedSQLstatement that is about to be executed, ornullif theSQLstatement is unknown..ExecuteContext.statement(): ThePreparedStatementthat is about to be executed, ornullif no statement is known to jOOQ. 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
Statementmay be closed!- A
ExecuteContext.resultSet(): TheResultSetthat was fetched ornull, if no result set was fetched. Note that theResultSetmay already be closed!ExecuteContext.rows(): The number of affected rows if applicable.ExecuteContext.serverOutput(): The server output if available. This may be fetched whenSettings.getFetchServerOutputSize()> 0ExecuteContext.record(): The lastRecordthat was fetched or null if no records were fetched.ExecuteContext.result(): The last set of records that were fetched or null if no records were fetched.ExecuteContext.sqlWarning(): TheSQLWarningthat was emitted by the databaseExecuteContext.exception(): TheRuntimeExceptionthat is about to be thrown ornull, if no exception is being thrown.ExecuteContext.sqlException(): TheSQLExceptionthat was thrown by the database ornull, if no exception is being thrown.
This method is only invoked if a warning appears. Note that fetching of warnings can be disabled using
Settings.isFetchWarnings()
-
-