- All Implemented Interfaces:
Serializable
,EventListener
,ExecuteListener
ExecuteListener
that just logs events to java.util.logging,
log4j, or slf4j using the JooqLogger
.
This is a stateful listener, meaning it has a reference to a
StopWatch
that is shared among all query executions that use this
same StopWatchListener
. If the instance is shared among query
executions, the listener measures the time passed since the first
initialisation. In order to let it measure the time for each individual query
execution afresh, use an ExecuteListenerProvider
to create new
instances every time:
configuration.set(StopWatchListener::new)
- Author:
- Lukas Eder
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
bindEnd
(ExecuteContext ctx) Called after bind variables to thePreparedStatement
.void
bindStart
(ExecuteContext ctx) Called before bind variables to thePreparedStatement
.void
end
(ExecuteContext ctx) Called at the end of the execution lifecycle.void
exception
(ExecuteContext ctx) Called in the event of an exception at any moment of the execution lifecycle.void
executeEnd
(ExecuteContext ctx) Called after executing a statement.void
Called before executing a statement.void
fetchEnd
(ExecuteContext ctx) Called after fetching data from aResultSet
.void
fetchStart
(ExecuteContext ctx) Called before fetching data from aResultSet
into aResult
type.void
outEnd
(ExecuteContext ctx) Called after fetching out parameter values from aCallableStatement
.void
outStart
(ExecuteContext ctx) Called before fetching out parameter values from aCallableStatement
.void
prepareEnd
(ExecuteContext ctx) Called after preparing / creating the SQL statement.void
Called before preparing / creating the SQL statement.void
recordEnd
(ExecuteContext ctx) Called after fetching a record from aResultSet
.void
Called before fetching a record from aResultSet
.void
renderEnd
(ExecuteContext ctx) Called after rendering SQL from aQueryPart
.void
Called before rendering SQL from aQueryPart
.void
resultEnd
(ExecuteContext ctx) Called after fetching a set of records from aResultSet
.void
Called before fetching a set of records from aResultSet
.void
start
(ExecuteContext ctx) Called to initialise anExecuteListener
.void
warning
(ExecuteContext ctx) Called in the event of a warning at any moment of the execution lifecycle.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jooq.ExecuteListener
transformEnd, transformStart
-
Constructor Details
-
StopWatchListener
public StopWatchListener()
-
-
Method Details
-
start
Description copied from interface:ExecuteListener
Called to initialise anExecuteListener
.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwise
ExecuteContext
:ExecuteContext.connectionProvider(ConnectionProvider)
: The connection provider used for execution. This may be particularly interesting if aQuery
was de-serialised and is thus lacking the underlying connection
- Specified by:
start
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
renderStart
Description copied from interface:ExecuteListener
Called before rendering SQL from aQueryPart
.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwise
- Specified by:
renderStart
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
renderEnd
Description copied from interface:ExecuteListener
Called after rendering SQL from aQueryPart
.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.
Overridable attributes in
ExecuteContext
:ExecuteContext.sql(String)
: The renderedSQL
statement that is about to be executed. You can modify this statement freely.ExecuteContext.params(Param[])
: Bind values that are to be bound to thePreparedStatement
.
- Specified by:
renderEnd
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
prepareStart
Description copied from interface:ExecuteListener
Called before preparing / creating the SQL statement.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.
Overridable attributes in
ExecuteContext
:ExecuteContext.sql(String)
: The renderedSQL
statement that is about to be executed. You can modify this statement freely.ExecuteContext.params(Param[])
: Bind values that are to be bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
about 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
PreparedStatement
needs to take into accountSettings.getStatementType()
, and adefault void 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.
- Specified by:
prepareStart
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
prepareEnd
Description copied from interface:ExecuteListener
Called after preparing / creating the SQL statement.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.Statement
from your JDBC driver wrapped in ajava.sql.PreparedStatement
when your jOOQQuery
is being executed asStatementType.STATIC_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
- A
Overridable attributes in
ExecuteContext
:ExecuteContext.params(Param[])
: Bind values that are to be bound to thePreparedStatement
.ExecuteContext.statement(PreparedStatement)
: TheStatement
,PreparedStatement
, orCallableStatement
that is about to be executed. You can modify this statement freely, or wrapExecuteContext.statement()
with your enriched statement wrapper
- Specified by:
prepareEnd
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
bindStart
Description copied from interface:ExecuteListener
Called before bind variables to thePreparedStatement
.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
- A
Overridable attributes in
ExecuteContext
:ExecuteContext.params(Param[])
: Bind values that are to be bound to thePreparedStatement
.ExecuteContext.statement(PreparedStatement)
: ThePreparedStatement
, orCallableStatement
that 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
- Specified by:
bindStart
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
bindEnd
Description copied from interface:ExecuteListener
Called after bind variables to thePreparedStatement
.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
- A
Overridable attributes in
ExecuteContext
:ExecuteContext.statement(PreparedStatement)
: TheStatement
,PreparedStatement
, orCallableStatement
that 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
- Specified by:
bindEnd
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
executeStart
Description copied from interface:ExecuteListener
Called before executing a statement.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.Statement
from your JDBC driver wrapped in ajava.sql.PreparedStatement
when your jOOQQuery
is being executed asStatementType.STATIC_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
- A
Overridable attributes in
ExecuteContext
:ExecuteContext.statement(PreparedStatement)
: TheStatement
,PreparedStatement
, orCallableStatement
that 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.
- Specified by:
executeStart
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
executeEnd
Description copied from interface:ExecuteListener
Called after executing a statement.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.Statement
from your JDBC driver wrapped in ajava.sql.PreparedStatement
when your jOOQQuery
is being executed asStatementType.STATIC_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
- A
ExecuteContext.resultSet()
: TheResultSet
that is about to be fetched ornull
, if theQuery
returns no result set, or if aRoutine
is being executed.ExecuteContext.rows()
: The number of affected rows if applicable. In case aResultSet
is fetched, this number is only available at theExecuteListener.fetchEnd(ExecuteContext)
event.ExecuteContext.serverOutput()
: The server output if available. This may be fetched whenSettings.getFetchServerOutputSize()
> 0
Overridable attributes in
ExecuteContext
:ExecuteContext.resultSet(ResultSet)
: TheResultSet
that is about to be fetched. You can modify this result set freely, or wrapExecuteContext.resultSet()
with your enriched result set wrapper
- Specified by:
executeEnd
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
outStart
Description copied from interface:ExecuteListener
Called before fetching out parameter values from aCallableStatement
.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
- A
ExecuteContext.sqlWarning()
: TheSQLWarning
that was emitted by the database ornull
if no warning was emitted.
Note that this method is called only when executing standalone routine calls.
- Specified by:
outStart
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
outEnd
Description copied from interface:ExecuteListener
Called after fetching out parameter values from aCallableStatement
.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
- A
ExecuteContext.sqlWarning()
: TheSQLWarning
that was emitted by the database ornull
if no warning was emitted.
Note that this method is called only when executing standalone routine calls.
- Specified by:
outEnd
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
fetchStart
Description copied from interface:ExecuteListener
Called before fetching data from aResultSet
into aResult
type.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.Statement
from your JDBC driver wrapped in ajava.sql.PreparedStatement
when your jOOQQuery
is being executed asStatementType.STATIC_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
- A
ExecuteContext.resultSet()
: TheResultSet
that is about to be fetched.ExecuteContext.sqlWarning()
: TheSQLWarning
that was emitted by the database ornull
if no warning was emitted.
Overridable attributes in
ExecuteContext
:ExecuteContext.resultSet(ResultSet)
: TheResultSet
that 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
ResultSets
withResultQuery.fetchMany()
, this is called several times, once perResultSet
Note that this method is not called when executing queries that do not return a result, or when executing routines.
- Specified by:
fetchStart
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
resultStart
Description copied from interface:ExecuteListener
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()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.Statement
from your JDBC driver wrapped in ajava.sql.PreparedStatement
when your jOOQQuery
is being executed asStatementType.STATIC_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
- A
ExecuteContext.resultSet()
: TheResultSet
that is about to be fetched.ExecuteContext.result()
: The set of records that are about to be fetched.ExecuteContext.resultLevel()
: The result nesting level, in case the upcomingExecuteContext.result()
is aDSL.multiset(TableLike)
or other type of nested result.ExecuteContext.sqlWarning()
: TheSQLWarning
that was emitted by the database ornull
if no warning was emitted.
Executions without
Result
Not all types of execution produce results of type
Result
. For example, these do not:ResultQuery.iterator()
ResultQuery.stream()
ResultQuery.collect(Collector)
(including allCollector
based fetches, such as e.g. aResultQuery.fetchMap(Field, Field)
,ResultQuery.fetchGroups(Field, Field)
,ResultQuery.fetchSet(Field)
, and all the overloads)Publisher.subscribe(Subscriber)
ExecuteListener.resultStart(ExecuteContext)
event is fired.Note that this method is also 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.- Specified by:
resultStart
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
recordStart
Description copied from interface:ExecuteListener
Called before fetching a record from aResultSet
.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.Statement
from your JDBC driver wrapped in ajava.sql.PreparedStatement
when your jOOQQuery
is being executed asStatementType.STATIC_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
- A
ExecuteContext.resultSet()
: TheResultSet
that is about to be fetched.ExecuteContext.record()
: TheRecord
that is about to be fetched.ExecuteContext.recordLevel()
: The record nesting level, in case the upcomingExecuteContext.record()
is aRow
or other type of nested record. The level is also increased if a record is contained in a nestedExecuteContext.result()
.ExecuteContext.sqlWarning()
: TheSQLWarning
that was emitted by the database ornull
if no warning was emitted.
Note that this method is not called when executing queries that do not return a result, or when executing routines.
- Specified by:
recordStart
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
recordEnd
Description copied from interface:ExecuteListener
Called after fetching a record from aResultSet
.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.Statement
from your JDBC driver wrapped in ajava.sql.PreparedStatement
when your jOOQQuery
is being executed asStatementType.STATIC_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
- A
ExecuteContext.resultSet()
: TheResultSet
that is about to be fetched.ExecuteContext.record()
: The lastRecord
that was fetched.ExecuteContext.recordLevel()
: The record nesting level, in case the upcomingExecuteContext.record()
is aRow
or other type of nested record. The level is also increased if a record is contained in a nestedExecuteContext.result()
.ExecuteContext.sqlWarning()
: TheSQLWarning
that was emitted by the database ornull
if no warning was emitted.
Note that this method is not called when executing queries that do not return a result, or when executing routines.
- Specified by:
recordEnd
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
resultEnd
Description copied from interface:ExecuteListener
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()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.Statement
from your JDBC driver wrapped in ajava.sql.PreparedStatement
when your jOOQQuery
is being executed asStatementType.STATIC_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
- A
ExecuteContext.resultSet()
: TheResultSet
that is about to be fetched.ExecuteContext.record()
: The lastRecord
that was fetched.ExecuteContext.result()
: The set of records that were fetched.ExecuteContext.resultLevel()
: The result nesting level, in case the upcomingExecuteContext.result()
is aDSL.multiset(TableLike)
or other type of nested result.ExecuteContext.sqlWarning()
: TheSQLWarning
that was emitted by the database ornull
if no warning was emitted.
Executions without
Result
Not all types of execution produce results of type
Result
. For example, these do not:ResultQuery.iterator()
ResultQuery.stream()
ResultQuery.collect(Collector)
(including allCollector
based fetches, such as e.g. aResultQuery.fetchMap(Field, Field)
,ResultQuery.fetchGroups(Field, Field)
,ResultQuery.fetchSet(Field)
, and all the overloads)Publisher.subscribe(Subscriber)
ExecuteListener.resultEnd(ExecuteContext)
event is fired.Note that this method is also 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.- Specified by:
resultEnd
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
fetchEnd
Description copied from interface:ExecuteListener
Called after fetching data from aResultSet
.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.Statement
from your JDBC driver wrapped in ajava.sql.PreparedStatement
when your jOOQQuery
is being executed asStatementType.STATIC_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
Statement
is already closed!- A
ExecuteContext.resultSet()
: TheResultSet
that was fetched. Note that theResultSet
is 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 lastRecord
that was fetched.ExecuteContext.result()
: The last set of records that were fetched.ExecuteContext.sqlWarning()
: TheSQLWarning
that was emitted by the database ornull
if no warning was emitted.
In case of multiple
ResultSets
withResultQuery.fetchMany()
, this is called several times, once perResultSet
Note that this method is not called when executing queries that do not return a result, or when executing routines.
- Specified by:
fetchEnd
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
end
Description copied from interface:ExecuteListener
Called at the end of the execution lifecycle.Available attributes from
ExecuteContext
:ExecuteContext.connection()
: The connection used for executionScope.configuration()
: The execution configurationExecuteContext.query()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.Statement
from your JDBC driver wrapped in ajava.sql.PreparedStatement
when your jOOQQuery
is being executed asStatementType.STATIC_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
Statement
is already closed!- A
ExecuteContext.resultSet()
: TheResultSet
that was fetched ornull
, if no result set was fetched. Note that theResultSet
may 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 lastRecord
that 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()
: TheSQLWarning
that was emitted by the database ornull
if no warning was emitted.
- Specified by:
end
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
exception
Description copied from interface:ExecuteListener
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()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.Statement
from your JDBC driver wrapped in ajava.sql.PreparedStatement
when your jOOQQuery
is being executed asStatementType.STATIC_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
Statement
may be closed!- A
ExecuteContext.resultSet()
: TheResultSet
that was fetched ornull
, if no result set was fetched. Note that theResultSet
may 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 lastRecord
that 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()
: TheRuntimeException
that is about to be thrownExecuteContext.sqlException()
: TheSQLException
that was thrown by the database
- Specified by:
exception
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-
warning
Description copied from interface:ExecuteListener
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()
: TheQuery
object, if a jOOQ query is being executed ornull
otherwiseExecuteContext.routine()
: TheRoutine
object, if a jOOQ routine is being executed ornull
otherwiseExecuteContext.sql()
: The renderedSQL
statement that is about to be executed, ornull
if theSQL
statement is unknown.ExecuteContext.params()
: The bind values that are bound to thePreparedStatement
.ExecuteContext.statement()
: ThePreparedStatement
that is about to be executed, ornull
if no statement is known to jOOQ. This can be any of the following:
- A
java.sql.PreparedStatement
from your JDBC driver when a jOOQQuery
is being executed asStatementType.PREPARED_STATEMENT
- A
java.sql.Statement
from your JDBC driver wrapped in ajava.sql.PreparedStatement
when your jOOQQuery
is being executed asStatementType.STATIC_STATEMENT
- A
java.sql.CallableStatement
when you are executing a jOOQRoutine
Statement
may be closed!- A
ExecuteContext.resultSet()
: TheResultSet
that was fetched ornull
, if no result set was fetched. Note that theResultSet
may 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 lastRecord
that 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()
: TheSQLWarning
that was emitted by the databaseExecuteContext.exception()
: TheRuntimeException
that is about to be thrown ornull
, if no exception is being thrown.ExecuteContext.sqlException()
: TheSQLException
that 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()
- Specified by:
warning
in interfaceExecuteListener
- Parameters:
ctx
- The context containing information about the execution.
-