public class LoggerListener extends DefaultExecuteListener
ExecuteListener
that just logs events to java.util.logging,
log4j, or slf4j using the JooqLogger
Constructor and Description |
---|
LoggerListener() |
Modifier and Type | Method and Description |
---|---|
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
Available attributes from
ExecuteContext :
ExecuteContext.connection() : The connection used for
execution
Scope.configuration() : The execution configuration
ExecuteContext.query() : The Query object, if a
jOOQ query is being executed or null otherwise
ExecuteContext.routine() : The Routine object, if
a jOOQ routine is being executed or null otherwise
ExecuteContext.sql() : The rendered SQL statement
that is about to be executed, or null if the
SQL statement is unknown.. |
void |
outEnd(ExecuteContext ctx)
Called after fetching out parameter values from a
CallableStatement . |
void |
recordEnd(ExecuteContext ctx)
Called after fetching a record from a
ResultSet
Available attributes from ExecuteContext :
ExecuteContext.connection() : The connection used for
execution
Scope.configuration() : The execution configuration
ExecuteContext.query() : The Query object, if a
jOOQ query is being executed or null otherwise
ExecuteContext.routine() : The Routine object, if
a jOOQ routine is being executed or null otherwise
ExecuteContext.sql() : The rendered SQL statement
that is about to be executed, or null if the
SQL statement is unknown.. |
void |
renderEnd(ExecuteContext ctx)
Called after rendering SQL from a
QueryPart
Available attributes from ExecuteContext :
ExecuteContext.connection() : The connection used for
execution
Scope.configuration() : The execution configuration
ExecuteContext.query() : The Query object, if a
jOOQ query is being executed or null otherwise
ExecuteContext.routine() : The Routine object, if
a jOOQ routine is being executed or null otherwise
ExecuteContext.sql() : The rendered SQL statement
that is about to be executed, or null if the
SQL statement is unknown.. |
void |
resultEnd(ExecuteContext ctx)
Called after fetching a set of records from a
ResultSet
Available attributes from ExecuteContext :
ExecuteContext.connection() : The connection used for
execution
Scope.configuration() : The execution configuration
ExecuteContext.query() : The Query object, if a
jOOQ query is being executed or null otherwise
ExecuteContext.routine() : The Routine object, if
a jOOQ routine is being executed or null otherwise
ExecuteContext.sql() : The rendered SQL statement
that is about to be executed, or null if the
SQL statement is unknown.. |
bindEnd, bindStart, end, executeStart, fetchEnd, fetchStart, outStart, prepareEnd, prepareStart, recordStart, renderStart, resultStart, start, warning
public void renderEnd(ExecuteContext ctx)
ExecuteListener
QueryPart
Available attributes from ExecuteContext
:
ExecuteContext.connection()
: The connection used for
executionScope.configuration()
: The execution configurationExecuteContext.query()
: The Query
object, if a
jOOQ query is being executed or null
otherwiseExecuteContext.routine()
: The Routine
object, if
a jOOQ routine is being executed or null
otherwiseExecuteContext.sql()
: The rendered SQL
statement
that is about to be executed, or null
if the
SQL
statement is unknown..
Overridable attributes in ExecuteContext
:
ExecuteContext.sql(String)
: The rendered SQL
statement that is about to be executed. You can modify this statement
freely.renderEnd
in interface ExecuteListener
renderEnd
in class DefaultExecuteListener
public void recordEnd(ExecuteContext ctx)
ExecuteListener
ResultSet
Available attributes from ExecuteContext
:
ExecuteContext.connection()
: The connection used for
executionScope.configuration()
: The execution configurationExecuteContext.query()
: The Query
object, if a
jOOQ query is being executed or null
otherwiseExecuteContext.routine()
: The Routine
object, if
a jOOQ routine is being executed or null
otherwiseExecuteContext.sql()
: The rendered SQL
statement
that is about to be executed, or null
if the
SQL
statement is unknown..ExecuteContext.statement()
: The
PreparedStatement
that is about to be executed, or
null
if no statement is known to jOOQ. This can be any of
the following: java.sql.PreparedStatement
from your JDBC driver when
a jOOQ Query
is being executed as
StatementType.PREPARED_STATEMENT
java.sql.Statement
from your JDBC driver wrapped in a
java.sql.PreparedStatement
when your jOOQ Query
is being executed as StatementType.STATIC_STATEMENT
java.sql.CallableStatement
when you are executing a
jOOQ Routine
ExecuteContext.resultSet()
: The ResultSet
that
is about to be fetched.ExecuteContext.record()
: The last Record
that
was fetched.ExecuteContext.sqlWarning()
: The SQLWarning
that was
emitted by the database or null
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.
recordEnd
in interface ExecuteListener
recordEnd
in class DefaultExecuteListener
public void resultEnd(ExecuteContext ctx)
ExecuteListener
ResultSet
Available attributes from ExecuteContext
:
ExecuteContext.connection()
: The connection used for
executionScope.configuration()
: The execution configurationExecuteContext.query()
: The Query
object, if a
jOOQ query is being executed or null
otherwiseExecuteContext.routine()
: The Routine
object, if
a jOOQ routine is being executed or null
otherwiseExecuteContext.sql()
: The rendered SQL
statement
that is about to be executed, or null
if the
SQL
statement is unknown..ExecuteContext.statement()
: The
PreparedStatement
that is about to be executed, or
null
if no statement is known to jOOQ. This can be any of
the following: java.sql.PreparedStatement
from your JDBC driver when
a jOOQ Query
is being executed as
StatementType.PREPARED_STATEMENT
java.sql.Statement
from your JDBC driver wrapped in a
java.sql.PreparedStatement
when your jOOQ Query
is being executed as StatementType.STATIC_STATEMENT
java.sql.CallableStatement
when you are executing a
jOOQ Routine
ExecuteContext.resultSet()
: The ResultSet
that
is about to be fetched.ExecuteContext.record()
: The last Record
that
was fetched.ExecuteContext.result()
: The set of records that were
fetched.ExecuteContext.sqlWarning()
: The SQLWarning
that was
emitted by the database or null
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. This is also not called when
fetching single records, with Cursor.fetchOne()
for instance.
resultEnd
in interface ExecuteListener
resultEnd
in class DefaultExecuteListener
public void executeEnd(ExecuteContext ctx)
ExecuteListener
Available attributes from ExecuteContext
:
ExecuteContext.connection()
: The connection used for
executionScope.configuration()
: The execution configurationExecuteContext.query()
: The Query
object, if a
jOOQ query is being executed or null
otherwiseExecuteContext.routine()
: The Routine
object, if
a jOOQ routine is being executed or null
otherwiseExecuteContext.sql()
: The rendered SQL
statement
that is about to be executed, or null
if the
SQL
statement is unknown..ExecuteContext.statement()
: The
PreparedStatement
that is about to be executed, or
null
if no statement is known to jOOQ. This can be any of
the following: java.sql.PreparedStatement
from your JDBC driver when
a jOOQ Query
is being executed as
StatementType.PREPARED_STATEMENT
java.sql.Statement
from your JDBC driver wrapped in a
java.sql.PreparedStatement
when your jOOQ Query
is being executed as StatementType.STATIC_STATEMENT
java.sql.CallableStatement
when you are executing a
jOOQ Routine
ExecuteContext.resultSet()
: The ResultSet
that
is about to be fetched or null
, if the Query
returns no result set, or if a Routine
is being executed.ExecuteContext.rows()
: The number of affected rows if
applicable. In case a ResultSet
is fetched, this number is only
available at the ExecuteListener.fetchEnd(ExecuteContext)
event.
Overridable attributes in ExecuteContext
:
ExecuteContext.resultSet(ResultSet)
: The
ResultSet
that is about to be fetched. You can modify this
result set freely, or wrap ExecuteContext.resultSet()
with your
enriched result set wrapperexecuteEnd
in interface ExecuteListener
executeEnd
in class DefaultExecuteListener
public void outEnd(ExecuteContext ctx)
ExecuteListener
CallableStatement
.
Available attributes from ExecuteContext
:
ExecuteContext.connection()
: The connection used for
executionScope.configuration()
: The execution configurationExecuteContext.routine()
: The Routine
object, if
a jOOQ routine is being executed or null
otherwiseExecuteContext.sql()
: The rendered SQL
statement
that is about to be executed, or null
if the
SQL
statement is unknown..ExecuteContext.statement()
: The
PreparedStatement
that is about to be executed, or
null
if no statement is known to jOOQ. This can be any of
the following: java.sql.CallableStatement
when you are executing a
jOOQ Routine
ExecuteContext.sqlWarning()
: The SQLWarning
that was
emitted by the database or null
if no warning was emitted.Note that this method is called only when executing standalone routine calls.
outEnd
in interface ExecuteListener
outEnd
in class DefaultExecuteListener
public void exception(ExecuteContext ctx)
ExecuteListener
Available attributes from ExecuteContext
:
ExecuteContext.connection()
: The connection used for
executionScope.configuration()
: The execution configurationExecuteContext.query()
: The Query
object, if a
jOOQ query is being executed or null
otherwiseExecuteContext.routine()
: The Routine
object, if
a jOOQ routine is being executed or null
otherwiseExecuteContext.sql()
: The rendered SQL
statement
that is about to be executed, or null
if the
SQL
statement is unknown..ExecuteContext.statement()
: The
PreparedStatement
that is about to be executed, or
null
if no statement is known to jOOQ. This can be any of
the following: java.sql.PreparedStatement
from your JDBC driver when
a jOOQ Query
is being executed as
StatementType.PREPARED_STATEMENT
java.sql.Statement
from your JDBC driver wrapped in a
java.sql.PreparedStatement
when your jOOQ Query
is being executed as StatementType.STATIC_STATEMENT
java.sql.CallableStatement
when you are executing a
jOOQ Routine
Statement
may be closed!ExecuteContext.resultSet()
: The ResultSet
that
was fetched or null
, if no result set was fetched. Note that
the ResultSet
may already be closed!ExecuteContext.rows()
: The number of affected rows if
applicable.ExecuteContext.record()
: The last Record
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()
: The RuntimeException
that
is about to be thrownExecuteContext.sqlException()
: The SQLException
that
was thrown by the databaseexception
in interface ExecuteListener
exception
in class DefaultExecuteListener
Copyright © 2016. All Rights Reserved.