- All Superinterfaces:
Attachable
,AttachableQueryPart
,AutoCloseable
,Query
,QueryPart
,Serializable
,Statement
- All Known Subinterfaces:
CloseableResultQuery<R>
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 TypeMethodDescription@NotNull CloseableQuery
Bind a new value to an indexed parameter.@NotNull CloseableQuery
Bind a new value to a named parameter.void
close()
Close the underlying statement.@NotNull CloseableQuery
keepStatement
(boolean keepStatement) Keep the query's underlying statement open after execution.@NotNull CloseableQuery
poolable
(boolean poolable) Specify whether any JDBCStatement
created by this query should beStatement.setPoolable(boolean)
.@NotNull CloseableQuery
queryTimeout
(int seconds) Specify the query timeout in number of seconds for the underlying JDBCStatement
.Methods inherited from interface org.jooq.Attachable
attach, configuration, detach
Methods inherited from interface org.jooq.AttachableQueryPart
getBindValues, getParam, getParams, getSQL, getSQL
Methods inherited from interface org.jooq.Query
cancel, execute, executeAsync, executeAsync, isExecutable
-
Method Details
-
bind
@NotNull @NotNull CloseableQuery bind(String param, Object value) throws IllegalArgumentException, DataTypeException Description copied from interface:Query
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 withStatementType.STATIC_STATEMENT
and there is an underlyingPreparedStatement
kept open because ofQuery.keepStatement(boolean)
, the underlyingPreparedStatement
will be closed automatically in order for new bind values to have an effect.- Specified by:
bind
in interfaceQuery
- Parameters:
param
- The named parameter name. If this is a number, then this is the same as callingQuery.bind(int, Object)
value
- The new bind value.- Throws:
IllegalArgumentException
- if there is no parameter by the given parameter name or index.DataTypeException
- ifvalue
cannot be converted into the parameter's data type
-
bind
@NotNull @NotNull CloseableQuery bind(int index, Object value) throws IllegalArgumentException, DataTypeException Description copied from interface:Query
Bind a new value to an indexed parameter.Bind index order
The 1-based parameter index describes a parameter in rendering order, not in input order. For example, if a query contains aDSL.log(Field, Field)
call, where the first argument is thevalue
and the second argument is thebase
, this may produce different dialect specific renderings:- Db2:
ln(value) / ln(base)
- Oracle:
log(base, value)
- SQL Server:
log(value, base)
Some bind values may even be repeated by a dialect specific emulation, leading to duplication and index-shifting.
As such, it is usually better to supply bind values directly with the input of an expression, e.g.:
- Directly with the
DSL
method, such asDSL.log(Field, Field)
, for example. - With the plain SQL template constructor, e.g.
DSL.field(String, Object...)
- With the parser method, e.g.
Parser.parseField(String, Object...)
Inlined values
[#1886] If the bind value at
index
is inlined (Param.isInline()
) or if this query was created withStatementType.STATIC_STATEMENT
and there is an underlyingPreparedStatement
kept open because ofQuery.keepStatement(boolean)
, the underlyingPreparedStatement
will be closed automatically in order for new bind values to have an effect.- Specified by:
bind
in interfaceQuery
- Parameters:
index
- The parameter index in rendering order, starting with 1value
- The new bind value.- Throws:
IllegalArgumentException
- if there is no parameter by the given parameter index.DataTypeException
- ifvalue
cannot be converted into the parameter's data type
- Db2:
-
poolable
Description copied from interface:Query
Specify whether any JDBCStatement
created by this query should beStatement.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.
-
queryTimeout
Description copied from interface:Query
Specify the query timeout in number of seconds for the underlying JDBCStatement
.- Specified by:
queryTimeout
in interfaceQuery
- See Also:
-
keepStatement
Description copied from interface:Query
Keep the query's underlying statement open after execution.This indicates to jOOQ that the query's underlying
Statement
orPreparedStatement
should be kept open after execution. If it is kept open, client code is responsible for properly closing it usingclose()
, e.g. via atry-with-resources
statement.- Specified by:
keepStatement
in interfaceQuery
- Parameters:
keepStatement
- Whether to keep the underlying statement open
-
close
Close the underlying statement.This closes the query's underlying
Statement
orPreparedStatement
if a previous call tokeepStatement(boolean)
indicated that jOOQ should keep statements open after query execution. If there is no underlying open statement, this call is simply ignored.- Specified by:
close
in interfaceAutoCloseable
- Throws:
DataAccessException
- If something went wrong closing the statement- See Also:
-