Top Description Inners Methods
org.jooq

public Interface ExecuteContext

extends Scope
Known Direct Implementers
org.jooq.impl.DefaultExecuteContext, org.jooq.impl.SimpleExecuteContext
Imports
java.sql.Connection, .PreparedStatement, .ResultSet, .SQLException, .SQLWarning, .Statement, java.util.stream.Collector, org.jooq.conf.Settings, .StatementType, org.jooq.exception.DataAccessException, org.jooq.impl.DSL, org.jetbrains.annotations.NotNull, .Nullable

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 data() map contents are maintained for the entirety of the execution, and are passed along to child Scope types, including e.g.

Author
Lukas Eder
See Also
ExecuteListener

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ExecuteContext.BatchMode

The batch mode, which helps interpret the contents of ExecuteContext#batchQueries().

Method Summary

Modifier and TypeMethod and Description
public @NotNull ExecuteContext.BatchMode
batchMode()

The batch execution mode.

public @NotNull @NotNull Query[]

Returns:

The executed Query object(s). This is never null
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.

public @NotNull int[]

Returns:

The affected rows. This is never null
batchRows
()

The number of rows that were affected by the last statement executed in batch mode.

public @NotNull @NotNull String[]

Returns:

The generated SQL statement(s). This is never null
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.

public Connection
connection()

The connection to be used in this execute context.

public void
connectionProvider(ConnectionProvider connectionProvider)

Override the Connection that is being used for execution.

public ConverterContext
converterContext()

Get a ConverterContext for the scope of this ExecuteContext.

public @Nullable RuntimeException
exception()

The RuntimeException being thrown.

public void
exception(RuntimeException e)

Override the RuntimeException being thrown.

public @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.

public @Nullable Record
record()

The last record that was fetched from the result set, or null if no record has been fetched.

public void
record(Record record)

Calling this has no effect.

public 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).

public @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.

public void
result(Result<?> result)

Calling this has no effect.

public 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).

public @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.

public void
resultSet(ResultSet resultSet)

Override the ResultSet that is being fetched.

public @Nullable Routine<?>
routine()

The jOOQ Routine that is being executed or null if the query is unknown or if there was no jOOQ Routine.

public int
rows()

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

public void
rows(int rows)

Calling this has no effect.

public @NotNull @NotNull String[]

Returns:

The server output. This is never null.
serverOutput
()

Any server output collected from this statement when Settings#getFetchServerOutputSize() > 0.

public void
serverOutput(String[] output)

Any server output collected from this statement when Settings#getFetchServerOutputSize() > 0.

public @Nullable String
sql()

The SQL that is being executed or null if the SQL statement is unknown or if there was no SQL statement.

public void
sql(String sql)

Override the SQL statement that is being executed.

public @Nullable SQLException
sqlException()

The SQLException that was thrown by the database.

public void
sqlException(SQLException e)

Override the SQLException being thrown.

public @Nullable SQLWarning
sqlWarning()

The SQLWarning that was emitted by the database.

public void
sqlWarning(SQLWarning e)

Override the SQLWarning being emitted.

public @Nullable PreparedStatement
statement()

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

public void
statement(PreparedStatement statement)

Override the PreparedStatement that is being executed.

public int
statementExecutionCount()

The number of times this particular statement has been executed.

public @NotNull ExecuteType
type()

The type of database interaction that is being executed.

Inherited from org.jooq.Scope:
configurationcreationTimedatadatadatadialectdslfamilysettings

Method Detail

batchModeback to summary
public @NotNull ExecuteContext.BatchMode batchMode()

The batch execution mode.

Annotations
@NotNull
batchQueriesback to summary
public @NotNull @NotNull Query[] 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

Refer to batchMode() to decide how to interpret this content.

This corresponds to transformedBatchQueries().

Returns:@NotNull @NotNull Query[]

The executed Query object(s). This is never null

Annotations
@NotNull
See Also
query(), routine()
batchRowsback to summary
public @NotNull int[] 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:@NotNull int[]

The affected rows. This is never null

See Also
rows()
batchSQLback to summary
public @NotNull @NotNull String[] 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:@NotNull @NotNull String[]

The generated SQL statement(s). This is never null

Annotations
@NotNull
See Also
query(), routine()
connectionback to summary
public 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:

connectionProviderback to summary
public 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
ExecuteListener#start(ExecuteContext)
converterContextback to summary
public ConverterContext converterContext()

Get a ConverterContext for the scope of this ExecuteContext.

exceptionback to summary
public @Nullable RuntimeException exception()

The RuntimeException being thrown.

Annotations
@Nullable
exceptionback to summary
public 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.

queryback to summary
public @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.

This corresponds to transformedQuery().

Annotations
@Nullable
See Also
routine(), batchQueries()
recordback to summary
public @Nullable Record record()

The last record that was fetched from the result set, or null if no record has been fetched.

Annotations
@Nullable
recordback to summary
public void record(Record record)

Calling this has no effect. It is used by jOOQ internally.

recordLevelback to summary
public 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).

resultback to summary
public @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.

Annotations
@Nullable
resultback to summary
public void result(Result<?> result)

Calling this has no effect. It is used by jOOQ internally.

resultLevelback to summary
public 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).

resultSetback to summary
public @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.

Annotations
@Nullable
resultSetback to summary
public void resultSet(ResultSet resultSet)

Override the ResultSet that is being fetched.

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

See Also
ExecuteListener#executeEnd(ExecuteContext), ExecuteListener#fetchStart(ExecuteContext)
routineback to summary
public @Nullable Routine<?> routine()

The jOOQ Routine that is being executed or null if the query is unknown or if there was no jOOQ Routine.

Annotations
@Nullable
See Also
routine()
rowsback to summary
public int rows()

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

This returns -1:

rowsback to summary
public void rows(int rows)

Calling this has no effect. It is used by jOOQ internally.

serverOutputback to summary
public @NotNull @NotNull String[] serverOutput()

Any server output collected from this statement when Settings#getFetchServerOutputSize() > 0.

Returns:@NotNull @NotNull String[]

The server output. This is never null.

Annotations
@NotNull
serverOutputback to summary
public void serverOutput(String[] output)

Any server output collected from this statement when Settings#getFetchServerOutputSize() > 0.

sqlback to summary
public @Nullable String sql()

The SQL that is being executed or null if the SQL statement is unknown or if there was no SQL statement.

Annotations
@Nullable
sqlback to summary
public 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
ExecuteListener#renderEnd(ExecuteContext), ExecuteListener#prepareStart(ExecuteContext)
sqlExceptionback to summary
public @Nullable SQLException sqlException()

The SQLException that was thrown by the database.

Annotations
@Nullable
sqlExceptionback to summary
public 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.

sqlWarningback to summary
public @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.

Annotations
@Nullable
sqlWarningback to summary
public void sqlWarning(SQLWarning e)

Override the SQLWarning being emitted.

statementback to summary
public @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
Annotations
@Nullable
statementback to summary
public void statement(PreparedStatement statement)

Override the PreparedStatement that is being executed.

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

See Also
ExecuteListener#prepareEnd(ExecuteContext), ExecuteListener#bindStart(ExecuteContext)
statementExecutionCountback to summary
public 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
ExecuteListener#executeStart(ExecuteContext)
typeback to summary
public @NotNull ExecuteType type()

The type of database interaction that is being executed.

Annotations
@NotNull
See Also
ExecuteType
org.jooq back to summary

public final Enum ExecuteContext.BatchMode

extends Enum<ExecuteContext.BatchMode>
Class Inheritance

The batch mode, which helps interpret the contents of ExecuteContext#batchQueries().

Field Summary

Modifier and TypeField and Description
public static final ExecuteContext.BatchMode
MULTIPLE

A Batch with multiple static Statement and no bind variables is being executed.

public static final ExecuteContext.BatchMode
NONE

No Batch is being executed, but a single ExecuteContext#query() or a ExecuteContext#routine().

public static final ExecuteContext.BatchMode
SINGLE

A Batch with a single PreparedStatement and multiple bind variable sets is being executed.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ExecuteContext.BatchMode
public static ExecuteContext.BatchMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

MULTIPLEback to summary
public static final ExecuteContext.BatchMode MULTIPLE

A Batch with multiple static Statement and no bind variables is being executed.

NONEback to summary
public static final ExecuteContext.BatchMode NONE

No Batch is being executed, but a single ExecuteContext#query() or a ExecuteContext#routine().

SINGLEback to summary
public static final ExecuteContext.BatchMode SINGLE

A Batch with a single PreparedStatement and multiple bind variable sets is being executed.

Constructor Detail

BatchModeback to summary
private BatchMode()

Method Detail

valueOfback to summary
public static ExecuteContext.BatchMode valueOf(String name)
valuesback to summary
public static ExecuteContext.BatchMode[] values()