Module org.jooq
Package org.jooq

Interface ExecuteContext

All Superinterfaces:
Scope

public interface ExecuteContext extends Scope
A context object for Query execution passed to registered ExecuteListener's.

This type implements Scope and thus has a lifecycle defined by the query execution.

The Scope.data() map contents are maintained for the entirety of the execution, and are passed along to child Scope types, including e.g.

  • BindingScope: When passing bind values or reading results.
Author:
Lukas Eder
See Also:
  • Method Details

    • connection

      Connection connection()
      The connection to be used in this execute context.

      This returns a proxy to the Configuration.connectionProvider() 's supplied connection. This proxy takes care of two things:

    • type

      @NotNull @NotNull ExecuteType type()
      The type of database interaction that is being executed.
      See Also:
    • query

      @Nullable @Nullable Query query()
      The jOOQ Query that is being executed or null if the query is unknown, if it is a batch query, or if there was no jOOQ Query.
      See Also:
    • batchQueries

      @NotNull @NotNull Query @NotNull [] batchQueries()
      The jOOQ Query objects that are being executed in batch mode, or empty if the query is unknown or if there was no jOOQ Query.

      If a single Query is executed in non-batch mode, this will return an array of length 1, containing that Query

      Returns:
      The executed Query object(s). This is never null
      See Also:
    • routine

      @Nullable @Nullable Routine<?> routine()
      The jOOQ Routine that is being executed or null if the query is unknown or if there was no jOOQ Routine.
      See Also:
    • sql

      @Nullable @Nullable String sql()
      The SQL that is being executed or null if the SQL statement is unknown or if there was no SQL statement.
    • sql

      void sql(String sql)
      Override the SQL statement that is being executed.

      This may have no effect, if called at the wrong moment.

      See Also:
    • batchSQL

      @NotNull @NotNull String @NotNull [] batchSQL()
      The generated SQL statements that are being executed in batch mode, or empty if the query is unknown or if there was no SQL statement.

      If a single Query is executed in non-batch mode, this will return an array of length 1, containing that Query

      Returns:
      The generated SQL statement(s). This is never null
      See Also:
    • connectionProvider

      void connectionProvider(ConnectionProvider connectionProvider)
      Override the Connection that is being used for execution.

      This may have no effect, if called at the wrong moment.

      See Also:
    • statement

      @Nullable @Nullable PreparedStatement statement()
      The PreparedStatement that is being executed or null if the statement is unknown or if there was no statement.

      This can be any of the following:

      • A java.sql.PreparedStatement from your JDBC driver when a jOOQ Query is being executed as StatementType.PREPARED_STATEMENT
      • A java.sql.Statement from your JDBC driver wrapped in a java.sql.PreparedStatement when your jOOQ Query is being executed as StatementType.STATIC_STATEMENT
      • A java.sql.CallableStatement when you are executing a jOOQ Routine
    • statement

      void statement(PreparedStatement statement)
      Override the PreparedStatement that is being executed.

      This may have no effect, if called at the wrong moment.

      See Also:
    • statementExecutionCount

      int statementExecutionCount()
      The number of times this particular statement has been executed.

      Statements that are prepared by jOOQ can be executed multiple times without being closed if Query.keepStatement(boolean) is activated.

      This value will increment as soon as the statement is about to be executed (at the ExecuteListener.executeStart(ExecuteContext) event).

      See Also:
    • resultSet

      @Nullable @Nullable ResultSet resultSet()
      The ResultSet that is being fetched or null if the result set is unknown or if no result set is being fetched.
    • resultSet

      void resultSet(ResultSet resultSet)
      Override the ResultSet that is being fetched.

      This may have no effect, if called at the wrong moment.

      See Also:
    • recordLevel

      int recordLevel()
      The 0-based record nesting level for record(), relevant when nested result events are triggered via ExecuteListener.resultStart(ExecuteContext) and ExecuteListener.resultEnd(ExecuteContext), e.g. in the presence of DSL#multiset(Select).
    • record

      @Nullable @Nullable Record record()
      The last record that was fetched from the result set, or null if no record has been fetched.
    • record

      @Internal void record(Record record)
      Set the last record that was fetched from the result set.

      Users shouldn't call this method, it is used by jOOQ internally.

    • rows

      int rows()
      The number of rows that were affected by the last statement.

      This returns -1:

    • rows

      @Internal void rows(int rows)
      Set the number of rows that were affected by the last statement.

      Users shouldn't call this method, it is used by jOOQ internally.

    • batchRows

      int @NotNull [] batchRows()
      The number of rows that were affected by the last statement executed in batch mode.

      If a single Query is executed in non-batch mode, this will return an array of length 1, containing rows()

      This returns -1 values if the number of affected rows is not yet available, or if affected rows are not applicable for a given statement.

      Returns:
      The affected rows. This is never null
      See Also:
    • resultLevel

      int resultLevel()
      The 0-based result nesting level for result(), relevant when nested result events are triggered via ExecuteListener.resultStart(ExecuteContext) and ExecuteListener.resultEnd(ExecuteContext), e.g. in the presence of DSL#multiset(Select).
    • result

      @Nullable @Nullable Result<?> result()
      The last result that was fetched from the result set, or null if no result has been fetched, including when results do not need to be buffered in a Result type, such as all ResultQuery.collect(Collector) or ResultQuery.iterator() based fetches.
    • result

      @Internal void result(Result<?> result)
      Set the last result that was fetched from the result set.

      Users shouldn't call this method, it is used by jOOQ internally.

    • exception

      @Nullable @Nullable RuntimeException exception()
      The RuntimeException being thrown.
    • exception

      void exception(RuntimeException e)
      Override the RuntimeException being thrown.

      This may have no effect, if called at the wrong moment.

      If null is being passed, jOOQ will internally translate the "unavailable" exception to an unspecified DataAccessException.

    • sqlException

      @Nullable @Nullable SQLException sqlException()
      The SQLException that was thrown by the database.
    • sqlException

      void sqlException(SQLException e)
      Override the SQLException being thrown.

      Any SQLException will be wrapped by jOOQ using an unchecked DataAccessException. To have jOOQ throw your own custom RuntimeException, use exception(RuntimeException) instead. This may have no effect, if called at the wrong moment.

      If null is being passed, jOOQ will internally translate the "unavailable" exception to an unspecified DataAccessException.

    • sqlWarning

      @Nullable @Nullable SQLWarning sqlWarning()
      The SQLWarning that was emitted by the database.

      Note that fetching of warnings can be disabled using Settings.isFetchWarnings(), in case of which this property will be null.

    • sqlWarning

      void sqlWarning(SQLWarning e)
      Override the SQLWarning being emitted.
    • serverOutput

      @NotNull @NotNull String @NotNull [] serverOutput()
      Any server output collected from this statement when Settings.getFetchServerOutputSize() > 0.
      Returns:
      The server output. This is never null.
    • serverOutput

      void serverOutput(String[] output)
      Any server output collected from this statement when Settings.getFetchServerOutputSize() > 0.