Class LoggerListener
- java.lang.Object
-
- org.jooq.impl.DefaultExecuteListener
-
- org.jooq.tools.LoggerListener
-
- All Implemented Interfaces:
java.io.Serializable,java.util.EventListener,ExecuteListener
public class LoggerListener extends DefaultExecuteListener
A defaultExecuteListenerthat just logs events to java.util.logging, log4j, or slf4j using theJooqLogger- Author:
- Lukas Eder
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LoggerListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.voidoutEnd(ExecuteContext ctx)Called after fetching out parameter values from aCallableStatement.voidrecordEnd(ExecuteContext ctx)Called after fetching a record from aResultSet.voidrenderEnd(ExecuteContext ctx)Called after rendering SQL from aQueryPart.voidresultEnd(ExecuteContext ctx)Called after fetching a set of records from aResultSet.-
Methods inherited from class org.jooq.impl.DefaultExecuteListener
bindEnd, bindStart, end, executeStart, fetchEnd, fetchStart, outStart, prepareEnd, prepareStart, recordStart, renderStart, resultStart, start, warning
-
-
-
-
Method Detail
-
renderEnd
public void renderEnd(ExecuteContext ctx)
Description copied from interface:ExecuteListenerCalled 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.
- Specified by:
renderEndin interfaceExecuteListener- Overrides:
renderEndin classDefaultExecuteListener
-
recordEnd
public void recordEnd(ExecuteContext ctx)
Description copied from interface:ExecuteListenerCalled 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.
- Specified by:
recordEndin interfaceExecuteListener- Overrides:
recordEndin classDefaultExecuteListener
-
resultEnd
public void resultEnd(ExecuteContext ctx)
Description copied from interface:ExecuteListenerCalled 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.- Specified by:
resultEndin interfaceExecuteListener- Overrides:
resultEndin classDefaultExecuteListener
-
executeEnd
public void executeEnd(ExecuteContext ctx)
Description copied from interface:ExecuteListenerCalled 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 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): TheResultSetthat is about to be fetched. You can modify this result set freely, or wrapExecuteContext.resultSet()with your enriched result set wrapper
- Specified by:
executeEndin interfaceExecuteListener- Overrides:
executeEndin classDefaultExecuteListener
-
outEnd
public void outEnd(ExecuteContext ctx)
Description copied from interface:ExecuteListenerCalled 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.
- Specified by:
outEndin interfaceExecuteListener- Overrides:
outEndin classDefaultExecuteListener
-
exception
public void exception(ExecuteContext ctx)
Description copied from interface:ExecuteListenerCalled 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
- Specified by:
exceptionin interfaceExecuteListener- Overrides:
exceptionin classDefaultExecuteListener
-
-