diff --git a/jOOQ-test/src/org/jooq/test/_/testcases/ExecuteListenerTests.java b/jOOQ-test/src/org/jooq/test/_/testcases/ExecuteListenerTests.java
index beeee09b06..36fccb9b75 100644
--- a/jOOQ-test/src/org/jooq/test/_/testcases/ExecuteListenerTests.java
+++ b/jOOQ-test/src/org/jooq/test/_/testcases/ExecuteListenerTests.java
@@ -53,7 +53,6 @@ import java.util.List;
import java.util.Queue;
import org.jooq.ExecuteContext;
-import org.jooq.ExecuteListener;
import org.jooq.ExecuteType;
import org.jooq.Field;
import org.jooq.Result;
@@ -61,6 +60,7 @@ import org.jooq.TableRecord;
import org.jooq.UpdatableRecord;
import org.jooq.conf.Settings;
import org.jooq.conf.SettingsTools;
+import org.jooq.impl.DefaultExecuteListener;
import org.jooq.impl.Factory;
import org.jooq.test.BaseTest;
import org.jooq.test.jOOQAbstractTest;
@@ -92,6 +92,26 @@ extends BaseTest
+ * This may have no effect, if called at the wrong moment.
*
* @see ExecuteListener#renderEnd(ExecuteContext)
* @see ExecuteListener#prepareStart(ExecuteContext)
@@ -133,8 +136,9 @@ public interface ExecuteContext extends Configuration {
Connection getConnection();
/**
- * Override the {@link Connection} that is being used for execution. This
- * may have no effect, if called at the wrong moment.
+ * Override the {@link Connection} that is being used for execution.
+ *
+ * This may have no effect, if called at the wrong moment.
*
* @see ExecuteListener#start(ExecuteContext)
*/
@@ -161,8 +165,9 @@ public interface ExecuteContext extends Configuration {
PreparedStatement statement();
/**
- * Override the {@link PreparedStatement} that is being executed. This may
- * have no effect, if called at the wrong moment.
+ * Override the {@link PreparedStatement} that is being executed.
+ *
+ * This may have no effect, if called at the wrong moment.
*
* @see ExecuteListener#prepareEnd(ExecuteContext)
* @see ExecuteListener#bindStart(ExecuteContext)
@@ -176,8 +181,9 @@ public interface ExecuteContext extends Configuration {
ResultSet resultSet();
/**
- * Override the {@link ResultSet} that is being fetched. This may have no
- * effect, if called at the wrong moment.
+ * Override the {@link ResultSet} that is being fetched.
+ *
+ * This may have no effect, if called at the wrong moment.
*
* @see ExecuteListener#executeEnd(ExecuteContext)
* @see ExecuteListener#fetchStart(ExecuteContext)
@@ -205,4 +211,31 @@ public interface ExecuteContext extends Configuration {
* Calling this has no effect. It is being used by jOOQ internally.
*/
void result(Result> result);
+
+ /**
+ * The {@link RuntimeException} being thrown.
+ */
+ RuntimeException exception();
+
+ /**
+ * Override the {@link RuntimeException} being thrown.
+ *
+ * This may have no effect, if called at the wrong moment.
+ */
+ void exception(RuntimeException e);
+
+ /**
+ * The {@link SQLException} that was thrown by the database.
+ */
+ SQLException sqlException();
+
+ /**
+ * Override the {@link SQLException} being thrown.
+ *
+ * Any
* The following table explains how every type of statement / operation invokes
* callback methods in the correct order for all registered
@@ -220,6 +221,15 @@ import org.jooq.tools.StopWatchListener;
* SQLException will be wrapped by jOOQ using an unchecked
+ * {@link DataAccessException}. To have jOOQ throw your own custom
+ * {@link RuntimeException}, use {@link #exception(RuntimeException)}
+ * instead. This may have no effect, if called at the wrong moment.
+ */
+ void sqlException(SQLException e);
}
diff --git a/jOOQ/src/main/java/org/jooq/ExecuteListener.java b/jOOQ/src/main/java/org/jooq/ExecuteListener.java
index 696787b08c..d4a0099482 100644
--- a/jOOQ/src/main/java/org/jooq/ExecuteListener.java
+++ b/jOOQ/src/main/java/org/jooq/ExecuteListener.java
@@ -38,6 +38,7 @@ package org.jooq;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
+import java.sql.SQLException;
import org.jooq.conf.Settings;
import org.jooq.conf.StatementType;
@@ -56,11 +57,11 @@ import org.jooq.tools.StopWatchListener;
* Settings to
* {@link Factory#Factory(java.sql.Connection, SQLDialect, Settings)}. Advanced
* ExecuteListeners can also provide custom implementations of
- * {@link Connection}, {@link PreparedStatement} and {@link ResultSet} to jOOQ
- * in apropriate methods. For convenience, consider extending
- * {@link DefaultExecuteListener} instead of implementing this interface. This
- * will prevent compilation errors in future versions of jOOQ, when this
- * interface might get new methods.
+ * {@link Connection}, {@link PreparedStatement}, {@link ResultSet},
+ * {@link SQLException} or {@link RuntimeException} to jOOQ in apropriate
+ * methods. For convenience, consider extending {@link DefaultExecuteListener}
+ * instead of implementing this interface. This will prevent compilation errors
+ * in future versions of jOOQ, when this interface might get new methods.
*
* If nothing is specified, the default is to use {@link LoggerListener} and - * {@link StopWatchListener} as the only event listeners. + * {@link StopWatchListener} as the only event listeners, as configured in + * {@link Settings#isExecuteLogging()} * * @author Lukas Eder */ @@ -808,7 +819,7 @@ public interface ExecuteListener { void fetchEnd(ExecuteContext ctx); /** - * Called at the end of the execution lifecycle.. + * Called at the end of the execution lifecycle. *
* Available attributes from ExecuteContext:
*
Statement is already closed!
* ResultSet that
* was fetched or null, if no result set was fetched. Note that
- * if any ResultSet is already closed!ResultSet may already be closed!
* Record that
* was fetched or null if no records were fetched.
+ * Available attributes from ExecuteContext:
+ *
Query object, if a
+ * jOOQ query is being executed or null otherwiseRoutine object, if
+ * a jOOQ routine is being executed or null otherwiseSQL statement
+ * that is about to be executed, or null if the
+ * SQL statement is unknown..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
+ * {@link StatementType#PREPARED_STATEMENT}java.sql.Statement from your JDBC driver wrapped in a
+ * java.sql.PreparedStatement when your jOOQ Query
+ * is being executed as {@link StatementType#STATIC_STATEMENT}java.sql.CallableStatement when you are executing a
+ * jOOQ RoutineStatement may be closed!ResultSet that
+ * was fetched or null, if no result set was fetched. Note that
+ * the ResultSet may already be closed!Record that
+ * was fetched or null if no records were fetched.