Top Description Methods
org.jooq

public Interface CloseableQuery

extends Query, AutoCloseable
Known Direct Subinterfaces
org.jooq.CloseableResultQuery
Known Direct Implementers
org.jooq.impl.AbstractDelegatingQuery, org.jooq.impl.AbstractQuery
Imports
java.sql.PreparedStatement, java.util.concurrent.CompletionStage, .Executor, org.jooq.conf.StatementType, org.jooq.exception.DataAccessException, .DataTypeException, org.jooq.impl.DSL, org.jetbrains.annotations.Blocking, .NotNull

A Query that holds a reference to the underlying PreparedStatement without closing it, for reuse.

It was created via Query#keepStatement(boolean) and must be treated as a resource, e.g. in a try-with-resources statement.

Author
Lukas Eder

Method Summary

Modifier and TypeMethod and Description
public @NotNull CloseableQuery
bind(String
The named parameter name. If this is a number, then this is the same as calling bind(int, Object)
param
,
Object
The new bind value.
value
)

Redeclares org.jooq.Query.bind.

Bind a new value to a named parameter.
public @NotNull CloseableQuery
bind(int
The parameter index, starting with 1
index
,
Object
The new bind value.
value
)

Redeclares org.jooq.Query.bind.

Bind a new value to an indexed parameter.
public void
close()

Redeclares java.lang.AutoCloseable.close.

Close the underlying statement.
public @NotNull CloseableQuery
keepStatement(boolean
Whether to keep the underlying statement open
keepStatement
)

Redeclares org.jooq.Query.keepStatement.

Keep the query's underlying statement open after execution.
public @NotNull CloseableQuery
poolable(boolean poolable)

Redeclares org.jooq.Query.poolable.

Specify whether any JDBC java.sql.Statement created by this query should be java.sql.Statement#setPoolable(boolean).
public @NotNull CloseableQuery
queryTimeout(int seconds)

Redeclares org.jooq.Query.queryTimeout.

Specify the query timeout in number of seconds for the underlying JDBC Statement.
Inherited from org.jooq.Query:
cancelexecuteexecuteAsyncexecuteAsyncisExecutable

Method Detail

bindback to summary
public @NotNull CloseableQuery bind(String param, Object value) throws IllegalArgumentException, DataTypeException

Redeclares org.jooq.Query.bind.

Doc from org.jooq.Query.bind.

Bind a new value to a named parameter.

[#1886] If the bind value with name param is inlined ( Param#isInline()) or if this query was created with StatementType#STATIC_STATEMENT and there is an underlying PreparedStatement kept open because of keepStatement(boolean), the underlying PreparedStatement will be closed automatically in order for new bind values to have an effect.

Parameters
param:String

The named parameter name. If this is a number, then this is the same as calling bind(int, Object)

value:Object

The new bind value.

Annotations
@Override
@NotNull
Exceptions
IllegalArgumentException:
if there is no parameter by the given parameter name or index.
DataTypeException:
if value cannot be converted into the parameter's data type
bindback to summary
public @NotNull CloseableQuery bind(int index, Object value) throws IllegalArgumentException, DataTypeException

Redeclares org.jooq.Query.bind.

Doc from org.jooq.Query.bind.

Bind a new value to an indexed parameter.

[#1886] If the bind value at index is inlined ( Param#isInline()) or if this query was created with StatementType#STATIC_STATEMENT and there is an underlying PreparedStatement kept open because of keepStatement(boolean), the underlying PreparedStatement will be closed automatically in order for new bind values to have an effect.

Parameters
index:int

The parameter index, starting with 1

value:Object

The new bind value.

Annotations
@Override
@NotNull
Exceptions
IllegalArgumentException:
if there is no parameter by the given parameter index.
DataTypeException:
if value cannot be converted into the parameter's data type
closeback to summary
public void close() throws DataAccessException

Redeclares java.lang.AutoCloseable.close.

Close the underlying statement.

This closes the query's underlying Statement or PreparedStatement if a previous call to keepStatement(boolean) indicated that jOOQ should keep statements open after query execution. If there is no underlying open statement, this call is simply ignored.

Annotations
@Override
Exceptions
DataAccessException:
If something went wrong closing the statement
See Also
java.sql.Statement#close()
keepStatementback to summary
public @NotNull CloseableQuery keepStatement(boolean keepStatement)

Redeclares org.jooq.Query.keepStatement.

Doc from org.jooq.Query.keepStatement.

Keep the query's underlying statement open after execution.

This indicates to jOOQ that the query's underlying Statement or PreparedStatement should be kept open after execution. If it is kept open, client code is responsible for properly closing it using CloseableQuery#close(), e.g. via a try-with-resources statement.

Parameters
keepStatement:boolean

Whether to keep the underlying statement open

Annotations
@Override
@NotNull
poolableback to summary
public @NotNull CloseableQuery poolable(boolean poolable)

Redeclares org.jooq.Query.poolable.

Doc from org.jooq.Query.poolable.

Specify whether any JDBC java.sql.Statement created by this query should be java.sql.Statement#setPoolable(boolean).

If this method is not called on jOOQ types, then jOOQ will not specify the flag on JDBC either, resulting in JDBC's default behaviour.

Annotations
@Override
@NotNull
queryTimeoutback to summary
public @NotNull CloseableQuery queryTimeout(int seconds)

Redeclares org.jooq.Query.queryTimeout.

Doc from org.jooq.Query.queryTimeout.

Specify the query timeout in number of seconds for the underlying JDBC Statement.

Annotations
@Override
@NotNull