Package com.landawn.abacus.jdbc
Class AbstractPreparedQuery<Stmt extends PreparedStatement,This extends AbstractPreparedQuery<Stmt,This>>
java.lang.Object
com.landawn.abacus.jdbc.AbstractPreparedQuery<Stmt,This>
- Type Parameters:
Stmt
-This
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
NamedQuery
,PreparedCallableQuery
,PreparedQuery
public abstract class AbstractPreparedQuery<Stmt extends PreparedStatement,This extends AbstractPreparedQuery<Stmt,This>>
extends Object
implements Closeable
Performance Tips:
Avoid unnecessary/repeated database calls.
Only fetch the columns you need or update the columns you want.
Index is the key point in a lot of database performance issues.
The backed
Generally, don't cache or reuse the instance of this class, except the
Remember: parameter/column index in
The backed
PreparedStatement/CallableStatement
will be closed by default
after any execution methods(which will trigger the backed PreparedStatement/CallableStatement
to be executed, for example: get/query/queryForInt/Long/../findFirst/findOnlyOne/list/execute/...).
except the 'closeAfterExecution'
flag is set to false
by calling #closeAfterExecution(false)
.
Generally, don't cache or reuse the instance of this class, except the
'closeAfterExecution'
flag is set to false
by calling #closeAfterExecution(false)
.
Remember: parameter/column index in
PreparedStatement/ResultSet
starts from 1, not 0.- Author:
- haiyangl
-
Method Summary
Modifier and TypeMethodDescriptionaddBatch()
Adds the batch.<T> This
addBatchParameters
(Collection<? extends T> batchParameters) <T> This
addBatchParameters
(Collection<? extends T> batchParameters, Jdbc.BiParametersSetter<? super This, ? super T> parametersSetter) <T> This
addBatchParameters
(Collection<? extends T> batchParameters, com.landawn.abacus.util.Throwables.TriConsumer<? super This, ? super Stmt, ? super T, ? extends SQLException> parametersSetter) <T> This
addBatchParameters
(Collection<? extends T> batchParameters, Class<T> type) <T> This
addBatchParameters
(Iterator<? extends T> batchParameters) <T> This
addBatchParameters
(Iterator<? extends T> batchParameters, Jdbc.BiParametersSetter<? super This, ? super T> parametersSetter) <T> This
addBatchParameters
(Iterator<? extends T> batchParameters, com.landawn.abacus.util.Throwables.TriConsumer<? super This, ? super Stmt, ? super T, ? extends SQLException> parametersSetter) <T> This
addBatchParameters
(Iterator<? extends T> batchParameters, Class<T> type) boolean
allMatch
(Jdbc.BiRowFilter rowFilter) boolean
allMatch
(Jdbc.RowFilter rowFilter) boolean
anyMatch
(Jdbc.BiRowFilter rowFilter) boolean
anyMatch
(Jdbc.RowFilter rowFilter) <R> com.landawn.abacus.util.ContinuableFuture<R>
asyncCall
(com.landawn.abacus.util.Throwables.Function<This, R, SQLException> sqlAction) Note: The openedConnection
andStatement
will be held on tillsqlAction
is completed by another thread.<R> com.landawn.abacus.util.ContinuableFuture<R>
asyncCall
(com.landawn.abacus.util.Throwables.Function<This, R, SQLException> sqlAction, Executor executor) Note: The openedConnection
andStatement
will be held on tillsqlAction
is completed by another thread.com.landawn.abacus.util.ContinuableFuture<Void>
asyncRun
(com.landawn.abacus.util.Throwables.Consumer<This, SQLException> sqlAction) Note: The openedConnection
andStatement
will be held on tillsqlAction
is completed by another thread.com.landawn.abacus.util.ContinuableFuture<Void>
asyncRun
(com.landawn.abacus.util.Throwables.Consumer<This, SQLException> sqlAction, Executor executor) Note: The openedConnection
andStatement
will be held on tillsqlAction
is completed by another thread.<ID> List<ID>
Returns the generated key if it exists.<ID> List<ID>
batchInsert
(Jdbc.BiRowMapper<ID> autoGeneratedKeyExtractor) <ID> List<ID>
batchInsert
(Jdbc.RowMapper<ID> autoGeneratedKeyExtractor) int[]
<T> com.landawn.abacus.util.Tuple.Tuple2<int[],
List<T>> batchUpdateAndReturnGeneratedKeys
(Jdbc.BiRowMapper<T> autoGeneratedKeyExtractor) <T> com.landawn.abacus.util.Tuple.Tuple2<int[],
List<T>> batchUpdateAndReturnGeneratedKeys
(Jdbc.RowMapper<T> autoGeneratedKeyExtractor) void
close()
Close.closeAfterExecution
(boolean closeAfterExecution) configStmt
(com.landawn.abacus.util.Throwables.BiConsumer<? super This, ? super Stmt, ? extends SQLException> stmtSetter) Configure thisPreparedQuery/Statement
bystmtSetter
.configStmt
(com.landawn.abacus.util.Throwables.Consumer<? super This, ? extends SQLException> stmtSetter) Configure thisPreparedQuery/Statement
bystmtSetter
.int
count()
Deprecated.may be misused and it's inefficient.int
count
(Jdbc.BiRowFilter rowFilter) int
count
(Jdbc.RowFilter rowFilter) boolean
execute()
void
executeThenAccept
(com.landawn.abacus.util.Throwables.BiConsumer<Boolean, ? super Stmt, SQLException> consumer) Execute then accept.void
executeThenAccept
(com.landawn.abacus.util.Throwables.Consumer<? super Stmt, SQLException> consumer) Execute then accept.<R> R
executeThenApply
(com.landawn.abacus.util.Throwables.BiFunction<Boolean, ? super Stmt, ? extends R, SQLException> getter) Execute then apply.<R> R
executeThenApply
(com.landawn.abacus.util.Throwables.Function<? super Stmt, ? extends R, SQLException> getter) Execute then apply.boolean
exists()
Note: usingselect 1 from ...
, notselect count(*) from ...
.<T> com.landawn.abacus.util.u.Optional<T>
findFirst
(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<T> rowMapper) Deprecated.Use {@link stream(BiRowFilter, BiRowMapper).first()} instead.<T> com.landawn.abacus.util.u.Optional<T>
findFirst
(Jdbc.BiRowMapper<T> rowMapper) <T> com.landawn.abacus.util.u.Optional<T>
findFirst
(Jdbc.RowFilter rowFilter, Jdbc.RowMapper<T> rowMapper) Deprecated.Use {@link stream(RowFilter, RowMapper).first()} instead.<T> com.landawn.abacus.util.u.Optional<T>
findFirst
(Jdbc.RowMapper<T> rowMapper) <T> com.landawn.abacus.util.u.Optional<T>
<T> T
findFirstOrNull
(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<T> rowMapper) Deprecated.Use {@link stream(BiRowFilter, BiRowMapper).first()} instead.<T> T
findFirstOrNull
(Jdbc.BiRowMapper<T> rowMapper) <T> T
findFirstOrNull
(Jdbc.RowFilter rowFilter, Jdbc.RowMapper<T> rowMapper) Deprecated.Use {@link stream(RowFilter, RowMapper).first()} instead.<T> T
findFirstOrNull
(Jdbc.RowMapper<T> rowMapper) <T> T
findFirstOrNull
(Class<T> targetClass) <T> com.landawn.abacus.util.u.Optional<T>
findOnlyOne
(Jdbc.BiRowMapper<T> rowMapper) <T> com.landawn.abacus.util.u.Optional<T>
findOnlyOne
(Jdbc.RowMapper<T> rowMapper) <T> com.landawn.abacus.util.u.Optional<T>
findOnlyOne
(Class<T> targetClass) <T> T
findOnlyOneOrNull
(Jdbc.BiRowMapper<T> rowMapper) <T> T
findOnlyOneOrNull
(Jdbc.RowMapper<T> rowMapper) <T> T
findOnlyOneOrNull
(Class<T> targetClass) void
foreach
(Class<?> entityClass, Consumer<com.landawn.abacus.util.NoCachingNoUpdating.DisposableObjArray> rowConsumer) void
void
forEach
(Jdbc.BiRowConsumer rowConsumer) void
forEach
(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowConsumer rowConsumer) void
forEach
(Jdbc.RowConsumer rowConsumer) void
forEach
(Jdbc.RowFilter rowFilter, Jdbc.RowConsumer rowConsumer) <T> com.landawn.abacus.util.u.Optional<T>
get
(Jdbc.BiRowMapper<T> rowMapper) Deprecated.replaced byfindOnlyOne
.<T> com.landawn.abacus.util.u.Optional<T>
get
(Jdbc.RowMapper<T> rowMapper) Deprecated.replaced byfindOnlyOne
.<T> com.landawn.abacus.util.u.Optional<T>
Deprecated.replaced byfindOnlyOne
.<T> T
gett
(Jdbc.BiRowMapper<T> rowMapper) Deprecated.replaced byfindOnlyOneOrNull
.<T> T
gett
(Jdbc.RowMapper<T> rowMapper) Deprecated.replaced byfindOnlyOneOrNull
.<T> T
Deprecated.replaced byfindOnlyOneOrNull
.void
ifExists
(Jdbc.BiRowConsumer rowConsumer) void
ifExists
(Jdbc.RowConsumer rowConsumer) void
ifExistsOrElse
(Jdbc.BiRowConsumer rowConsumer, com.landawn.abacus.util.Throwables.Runnable<SQLException> orElseAction) If exists or else.void
ifExistsOrElse
(Jdbc.RowConsumer rowConsumer, com.landawn.abacus.util.Throwables.Runnable<SQLException> orElseAction) If exists or else.<ID> com.landawn.abacus.util.u.Optional<ID>
insert()
Returns the generated key if it exists.<ID> com.landawn.abacus.util.u.Optional<ID>
insert
(Jdbc.BiRowMapper<ID> autoGeneratedKeyExtractor) <ID> com.landawn.abacus.util.u.Optional<ID>
insert
(Jdbc.RowMapper<ID> autoGeneratedKeyExtractor) long[]
Large batch update.long
list()
<T> List<T>
list
(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<T> rowMapper) <T> List<T>
list
(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<T> rowMapper, int maxResult) <T> List<T>
list
(Jdbc.BiRowMapper<T> rowMapper) <T> List<T>
list
(Jdbc.BiRowMapper<T> rowMapper, int maxResult) Deprecated.the result size should be limited in database server side by sql scripts.<T> List<T>
list
(Jdbc.RowFilter rowFilter, Jdbc.RowMapper<T> rowMapper) <T> List<T>
list
(Jdbc.RowFilter rowFilter, Jdbc.RowMapper<T> rowMapper, int maxResult) <T> List<T>
list
(Jdbc.RowMapper<T> rowMapper) <T> List<T>
list
(Jdbc.RowMapper<T> rowMapper, int maxResult) Deprecated.the result size should be limited in database server side by sql scripts.<T> List<T>
<T> List<T>
Deprecated.the result size should be limited in database server side by sql scripts.boolean
noneMatch
(Jdbc.BiRowFilter rowFilter) boolean
noneMatch
(Jdbc.RowFilter rowFilter) boolean
Why addingnotExists()
? not justexists() == false
or!exists()
? BecausenotExists()
is not minor case.com.landawn.abacus.util.DataSet
query()
<R> R
query
(Jdbc.BiResultExtractor<R> resultExtrator) <R> R
query
(Jdbc.ResultExtractor<R> resultExtrator) com.landawn.abacus.util.u.Nullable<BigDecimal>
Query big decimal.com.landawn.abacus.util.u.Nullable<BigInteger>
Query big integer.com.landawn.abacus.util.u.OptionalBoolean
Query for boolean.com.landawn.abacus.util.u.OptionalByte
Query for byte.com.landawn.abacus.util.u.OptionalChar
Query for char.com.landawn.abacus.util.u.Nullable<Date>
Query for date.com.landawn.abacus.util.u.OptionalDouble
Query for double.com.landawn.abacus.util.u.OptionalFloat
Query for float.com.landawn.abacus.util.u.OptionalInt
Query for int.com.landawn.abacus.util.u.OptionalLong
Query for long.com.landawn.abacus.util.u.OptionalShort
Query for short.<V> com.landawn.abacus.util.u.Optional<V>
queryForSingleNonNull
(Class<V> targetClass) Returns anOptional
describing the value in the first row/column if it exists, otherwise return an emptyOptional
.<V> com.landawn.abacus.util.u.Nullable<V>
queryForSingleResult
(Class<V> targetClass) Returns aNullable
describing the value in the first row/column if it exists, otherwise return an emptyNullable
.com.landawn.abacus.util.u.Nullable<String>
Query for string.com.landawn.abacus.util.u.Nullable<Time>
Query for time.com.landawn.abacus.util.u.Nullable<Timestamp>
Query for timestamp.<V> com.landawn.abacus.util.u.Optional<V>
queryForUniqueNonNull
(Class<V> targetClass) Returns anOptional
describing the value in the first row/column if it exists, otherwise return an emptyOptional
.<V> com.landawn.abacus.util.u.Nullable<V>
queryForUniqueResult
(Class<V> targetClass) Returns aNullable
describing the value in the first row/column if it exists, otherwise return an emptyNullable
.Sets the array.setAsciiStream
(int parameterIndex, InputStream inputStream) Sets the ascii stream.setAsciiStream
(int parameterIndex, InputStream inputStream, long length) Sets the ascii stream.setBigDecimal
(int parameterIndex, BigDecimal x) Sets the big decimal.setBinaryStream
(int parameterIndex, InputStream inputStream) Sets the binary stream.setBinaryStream
(int parameterIndex, InputStream inputStream, long length) Sets the binary stream.setBlob
(int parameterIndex, InputStream inputStream) Sets the blob.setBlob
(int parameterIndex, InputStream inputStream, long length) Sets the blob.Sets the blob.setBoolean
(int parameterIndex, boolean x) Sets the boolean.setBoolean
(int parameterIndex, Boolean x) Sets the boolean.setByte
(int parameterIndex, byte x) Sets the byte.Sets the byte.setBytes
(int parameterIndex, byte[] x) Sets the bytes.setCharacterStream
(int parameterIndex, Reader reader) Sets the character stream.setCharacterStream
(int parameterIndex, Reader reader, long length) Sets the character stream.Sets the clob.Sets the clob.Sets the clob.Sets the date.Sets the date.setDateForMultiPositions
(Date parameterValue, int... parameterIndices) setDateForMultiPositions
(Date parameterValue, int... parameterIndices) setDouble
(int parameterIndex, double x) Sets the double.Sets the double.setFetchDirection
(FetchDirection direction) Sets the fetch direction.setFetchSize
(int rows) Sets the fetch size.setFloat
(int parameterIndex, float x) Sets the float.Sets the float.setInt
(int parameterIndex, char x) Sets the int.setInt
(int parameterIndex, int x) Sets the int.Sets the int.Sets the int.setIntegerForMultiPositions
(Integer parameterValue, int... parameterIndices) Note: The reason for giving name:setIntegerForMultiPositions
, notsetIntForMultiPositions
is because of error: The method setIntForMultiPositions(int, int[]) is ambiguous for the typesetIntForMultiPositions
(int parameterValue, int... parameterIndices) setLargeMaxRows
(long max) Sets the large max rows.setLong
(int parameterIndex, long x) Sets the long.Sets the long.setLongForMultiPositions
(long parameterValue, int... parameterIndices) setLongForMultiPositions
(Long parameterValue, int... parameterIndices) setMaxFieldSize
(int max) Sets the max field size.setMaxRows
(int max) Sets the max rows.setNCharacterStream
(int parameterIndex, Reader reader) Sets the N character stream.setNCharacterStream
(int parameterIndex, Reader reader, long length) Sets the N character stream.Sets the N clob.Sets the N clob.Sets the N clob.setNull
(int parameterIndex, int sqlType) Sets the null.Sets the null.Sets the object.Sets the object.Sets the object.Sets the object.Sets the object.setObjectForMultiPositions
(Object parameterValue, int... parameterIndices) setParameter
(Jdbc.ParametersSetter<? super Stmt> paramSetter) <T> This
setParameter
(T parameter, Jdbc.BiParametersSetter<? super Stmt, ? super T> paramSetter) setParameters
(int[] parameters) Sets the parameters.setParameters
(long[] parameters) Sets the parameters.setParameters
(Jdbc.ParametersSetter<? super Stmt> paramsSetter) Sets the parameters.setParameters
(Object param1, Object param2, Object param3) Sets the parameters.setParameters
(Object param1, Object param2, Object param3, Object param4) Sets the parameters.Sets the parameters.setParameters
(Object param1, Object param2, Object param3, Object param4, Object param5, Object param6) Sets the parameters.setParameters
(Object param1, Object param2, Object param3, Object param4, Object param5, Object param6, Object param7) Sets the parameters.setParameters
(Object param1, Object param2, Object param3, Object param4, Object param5, Object param6, Object param7, Object param8) Sets the parameters.setParameters
(Object param1, Object param2, Object param3, Object param4, Object param5, Object param6, Object param7, Object param8, Object param9) Sets the parameters.setParameters
(String[] parameters) Sets the parameters.setParameters
(String param1, String param2) Sets the parameters.setParameters
(String param1, String param2, String param3) Sets the parameters.setParameters
(String param1, String param2, String param3, String param4) Sets the parameters.Sets the parameters.setParameters
(String param1, String param2, String param3, String param4, String param5, String param6) Sets the parameters.setParameters
(String param1, String param2, String param3, String param4, String param5, String param6, String param7) Sets the parameters.setParameters
(Collection<?> parameters) Sets the parameters.<T> This
setParameters
(Collection<? extends T> parameters, Class<T> type) Sets the parameters.<T> This
setParameters
(T[] parameters) Sets the parameters.<T> This
setParameters
(T parameters, Jdbc.BiParametersSetter<? super Stmt, ? super T> paramsSetter) Sets the parameters.setQueryTimeout
(int seconds) Sets the query timeout.Sets the ref.Sets the row id.setShort
(int parameterIndex, short x) Sets the short.Sets the short.Sets the SQLXML.setString
(int parameterIndex, char x) Sets the String.setString
(int parameterIndex, CharSequence x) Sets the string.Sets the string.setStringForMultiPositions
(String parameterValue, int... parameterIndices) Sets the time.Sets the time.setTimeForMultiPositions
(Time parameterValue, int... parameterIndices) setTimeForMultiPositions
(Date parameterValue, int... parameterIndices) setTimestamp
(int parameterIndex, Timestamp x) Sets the timestamp.setTimestamp
(int parameterIndex, Date x) Sets the timestamp.setTimestampForMultiPositions
(Timestamp parameterValue, int... parameterIndices) setTimestampForMultiPositions
(Date parameterValue, int... parameterIndices) settParameters
(int startParameterIndex, int[] parameters) Sets the parameters.settParameters
(int startParameterIndex, long[] parameters) Sets the parameters.settParameters
(int startParameterIndex, String[] parameters) Sets the parameters.settParameters
(int startParameterIndex, Collection<?> parameters) Sets the parameters.<T> This
settParameters
(int startParameterIndex, Collection<? extends T> parameters, Class<T> type) Sets the parameters.<T> This
settParameters
(int startParameterIndex, T[] parameters) Sets the parameters.settParameters
(Jdbc.ParametersSetter<? super This> paramsSetter) <T> This
settParameters
(T parameters, Jdbc.BiParametersSetter<? super This, ? super T> paramsSetter) Sets the URL.com.landawn.abacus.util.ExceptionalStream<Map<String,
Object>, SQLException> stream()
lazy-execution, lazy-fetch.<T> com.landawn.abacus.util.ExceptionalStream<T,
SQLException> stream
(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<T> rowMapper) lazy-execution, lazy-fetch.<T> com.landawn.abacus.util.ExceptionalStream<T,
SQLException> stream
(Jdbc.BiRowMapper<T> rowMapper) lazy-execution, lazy-fetch.<T> com.landawn.abacus.util.ExceptionalStream<T,
SQLException> stream
(Jdbc.RowFilter rowFilter, Jdbc.RowMapper<T> rowMapper) lazy-execution, lazy-fetch.<T> com.landawn.abacus.util.ExceptionalStream<T,
SQLException> stream
(Jdbc.RowMapper<T> rowMapper) lazy-execution, lazy-fetch.<T> com.landawn.abacus.util.ExceptionalStream<T,
SQLException> lazy-execution, lazy-fetch.int
update()
updateAndReturnGeneratedKeys
(Jdbc.BiRowMapper<T> autoGeneratedKeyExtractor) updateAndReturnGeneratedKeys
(Jdbc.RowMapper<T> autoGeneratedKeyExtractor)
-
Method Details
-
closeAfterExecution
- Parameters:
closeAfterExecution
- default istrue
.- Returns:
-
onClose
- Parameters:
closeHandler
- A task to execute after thisQuery
is closed- Returns:
-
setNull
Sets the null.- Parameters:
parameterIndex
- starts from 1, not 0.sqlType
-- Returns:
- Throws:
SQLException
- See Also:
-
setNull
Sets the null.- Parameters:
parameterIndex
- starts from 1, not 0.sqlType
-typeName
-- Returns:
- Throws:
SQLException
- See Also:
-
setBoolean
Sets the boolean.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setBoolean
Sets the boolean.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setByte
Sets the byte.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setByte
Sets the byte.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setShort
Sets the short.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setShort
Sets the short.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setInt
Sets the int.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setInt
Sets the int.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setInt
Sets the int.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setInt
Sets the int.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setLong
Sets the long.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setLong
Sets the long.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setFloat
Sets the float.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setFloat
Sets the float.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setDouble
Sets the double.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setDouble
Sets the double.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setBigDecimal
Sets the big decimal.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setString
Sets the string.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setString
Sets the string.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setString
- Throws:
SQLException
-
setString
Sets the String.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setDate
Sets the date.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setDate
Sets the date.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setTime
Sets the time.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setTime
Sets the time.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setTimestamp
Sets the timestamp.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setTimestamp
Sets the timestamp.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setBytes
Sets the bytes.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setAsciiStream
Sets the ascii stream.- Parameters:
parameterIndex
-inputStream
-- Returns:
- Throws:
SQLException
-
setAsciiStream
public This setAsciiStream(int parameterIndex, InputStream inputStream, long length) throws SQLException Sets the ascii stream.- Parameters:
parameterIndex
-inputStream
-length
-- Returns:
- Throws:
SQLException
-
setBinaryStream
Sets the binary stream.- Parameters:
parameterIndex
-inputStream
-- Returns:
- Throws:
SQLException
-
setBinaryStream
public This setBinaryStream(int parameterIndex, InputStream inputStream, long length) throws SQLException Sets the binary stream.- Parameters:
parameterIndex
-inputStream
-length
-- Returns:
- Throws:
SQLException
-
setCharacterStream
Sets the character stream.- Parameters:
parameterIndex
-reader
-- Returns:
- Throws:
SQLException
-
setCharacterStream
Sets the character stream.- Parameters:
parameterIndex
-reader
-length
-- Returns:
- Throws:
SQLException
-
setNCharacterStream
Sets the N character stream.- Parameters:
parameterIndex
-reader
-- Returns:
- Throws:
SQLException
-
setNCharacterStream
Sets the N character stream.- Parameters:
parameterIndex
-reader
-length
-- Returns:
- Throws:
SQLException
-
setBlob
Sets the blob.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setBlob
Sets the blob.- Parameters:
parameterIndex
-inputStream
-- Returns:
- Throws:
SQLException
-
setBlob
Sets the blob.- Parameters:
parameterIndex
-inputStream
-length
-- Returns:
- Throws:
SQLException
-
setClob
Sets the clob.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setClob
Sets the clob.- Parameters:
parameterIndex
-reader
-- Returns:
- Throws:
SQLException
-
setClob
Sets the clob.- Parameters:
parameterIndex
-reader
-length
-- Returns:
- Throws:
SQLException
-
setNClob
Sets the N clob.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setNClob
Sets the N clob.- Parameters:
parameterIndex
-reader
-- Returns:
- Throws:
SQLException
-
setNClob
Sets the N clob.- Parameters:
parameterIndex
-reader
-length
-- Returns:
- Throws:
SQLException
-
setURL
Sets the URL.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setArray
Sets the array.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setSQLXML
Sets the SQLXML.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setRef
Sets the ref.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setRowId
Sets the row id.- Parameters:
parameterIndex
-x
-- Returns:
- Throws:
SQLException
-
setObject
Sets the object.- Parameters:
parameterIndex
- starts from 1, not 0.x
-- Returns:
- Throws:
SQLException
-
setObject
Sets the object.- Parameters:
parameterIndex
- starts from 1, not 0.x
-sqlType
-- Returns:
- Throws:
SQLException
- See Also:
-
setObject
public This setObject(int parameterIndex, Object x, int sqlType, int scaleOrLength) throws SQLException Sets the object.- Parameters:
parameterIndex
- starts from 1, not 0.x
-sqlType
-scaleOrLength
-- Returns:
- Throws:
SQLException
- See Also:
-
setObject
Sets the object.- Parameters:
parameterIndex
-x
-sqlType
-- Returns:
- Throws:
SQLException
-
setObject
public This setObject(int parameterIndex, Object x, SQLType sqlType, int scaleOrLength) throws SQLException Sets the object.- Parameters:
parameterIndex
-x
-sqlType
-scaleOrLength
-- Returns:
- Throws:
SQLException
-
setObject
public This setObject(int parameterIndex, Object x, com.landawn.abacus.type.Type<Object> type) throws SQLException - Throws:
SQLException
-
setParameter
- Throws:
SQLException
-
setParameter
public <T> This setParameter(T parameter, Jdbc.BiParametersSetter<? super Stmt, ? super T> paramSetter) throws SQLException- Throws:
SQLException
-
setParameters
Sets the parameters.- Parameters:
param1
-param2
-- Returns:
- Throws:
SQLException
-
setParameters
Sets the parameters.- Parameters:
param1
-param2
-param3
-- Returns:
- Throws:
SQLException
-
setParameters
public This setParameters(String param1, String param2, String param3, String param4) throws SQLException Sets the parameters.- Parameters:
param1
-param2
-param3
-param4
-- Returns:
- Throws:
SQLException
-
setParameters
public This setParameters(String param1, String param2, String param3, String param4, String param5) throws SQLException Sets the parameters.- Parameters:
param1
-param2
-param3
-param4
-param5
-- Returns:
- Throws:
SQLException
-
setParameters
public This setParameters(String param1, String param2, String param3, String param4, String param5, String param6) throws SQLException Sets the parameters.- Parameters:
param1
-param2
-param3
-param4
-param5
-param6
-- Returns:
- Throws:
SQLException
-
setParameters
public This setParameters(String param1, String param2, String param3, String param4, String param5, String param6, String param7) throws SQLException Sets the parameters.- Parameters:
param1
-param2
-param3
-param4
-param5
-param6
-param7
-- Returns:
- Throws:
SQLException
-
setParameters
Sets the parameters.- Parameters:
param1
-param2
-param3
-- Returns:
- Throws:
SQLException
-
setParameters
public This setParameters(Object param1, Object param2, Object param3, Object param4) throws SQLException Sets the parameters.- Parameters:
param1
-param2
-param3
-param4
-- Returns:
- Throws:
SQLException
-
setParameters
public This setParameters(Object param1, Object param2, Object param3, Object param4, Object param5) throws SQLException Sets the parameters.- Parameters:
param1
-param2
-param3
-param4
-param5
-- Returns:
- Throws:
SQLException
-
setParameters
public This setParameters(Object param1, Object param2, Object param3, Object param4, Object param5, Object param6) throws SQLException Sets the parameters.- Parameters:
param1
-param2
-param3
-param4
-param5
-param6
-- Returns:
- Throws:
SQLException
-
setParameters
public This setParameters(Object param1, Object param2, Object param3, Object param4, Object param5, Object param6, Object param7) throws SQLException Sets the parameters.- Parameters:
param1
-param2
-param3
-param4
-param5
-param6
-param7
-- Returns:
- Throws:
SQLException
-
setParameters
public This setParameters(Object param1, Object param2, Object param3, Object param4, Object param5, Object param6, Object param7, Object param8) throws SQLException Sets the parameters.- Parameters:
param1
-param2
-param3
-param4
-param5
-param6
-param7
-param8
-- Returns:
- Throws:
SQLException
-
setParameters
public This setParameters(Object param1, Object param2, Object param3, Object param4, Object param5, Object param6, Object param7, Object param8, Object param9) throws SQLException Sets the parameters.- Parameters:
param1
-param2
-param3
-param4
-param5
-param6
-param7
-param8
-param9
-- Returns:
- Throws:
SQLException
-
setParameters
Sets the parameters.- Parameters:
parameters
-- Returns:
- Throws:
IllegalArgumentException
- if specifiedparameters
ortype
is null.SQLException
-
setParameters
Sets the parameters.- Parameters:
parameters
-- Returns:
- Throws:
IllegalArgumentException
- if specifiedparameters
ortype
is null.SQLException
-
setParameters
Sets the parameters.- Parameters:
parameters
-- Returns:
- Throws:
IllegalArgumentException
- if specifiedparameters
ortype
is null.SQLException
-
setParameters
Sets the parameters.- Parameters:
parameters
- it should be an array of concrete types. For example:String[]
,Date[]
.- Returns:
- Throws:
IllegalArgumentException
- if specifiedparameters
ortype
is null.SQLException
-
setParameters
Sets the parameters.- Parameters:
startParameterIndex
-parameters
-- Returns:
- Throws:
IllegalArgumentException
- if specifiedparameters
.SQLException
-
setParameters
public <T> This setParameters(Collection<? extends T> parameters, Class<T> type) throws IllegalArgumentException, SQLException Sets the parameters.- Type Parameters:
T
-- Parameters:
startParameterIndex
-parameters
-type
-- Returns:
- Throws:
IllegalArgumentException
- if specifiedparameters
ortype
is null.SQLException
-
settParameters
public This settParameters(int startParameterIndex, int[] parameters) throws IllegalArgumentException, SQLException Sets the parameters.- Parameters:
startParameterIndex
-parameters
-- Returns:
- Throws:
IllegalArgumentException
- if specifiedparameters
ortype
is null.SQLException
-
settParameters
public This settParameters(int startParameterIndex, long[] parameters) throws IllegalArgumentException, SQLException Sets the parameters.- Parameters:
startParameterIndex
-parameters
-- Returns:
- Throws:
IllegalArgumentException
- if specifiedparameters
ortype
is null.SQLException
-
settParameters
public This settParameters(int startParameterIndex, String[] parameters) throws IllegalArgumentException, SQLException Sets the parameters.- Parameters:
startParameterIndex
-parameters
-- Returns:
- Throws:
IllegalArgumentException
- if specifiedparameters
ortype
is null.SQLException
-
settParameters
public <T> This settParameters(int startParameterIndex, T[] parameters) throws IllegalArgumentException, SQLException Sets the parameters.- Type Parameters:
T
-- Parameters:
startParameterIndex
-parameters
- it should be an array of concrete types. For example:String[]
,Date[]
.- Returns:
- Throws:
IllegalArgumentException
- if specifiedparameters
ortype
is null.SQLException
-
settParameters
public This settParameters(int startParameterIndex, Collection<?> parameters) throws IllegalArgumentException, SQLException Sets the parameters.- Parameters:
startParameterIndex
-parameters
-type
-- Returns:
- Throws:
IllegalArgumentException
- if specifiedparameters
ortype
is null.SQLException
-
settParameters
public <T> This settParameters(int startParameterIndex, Collection<? extends T> parameters, Class<T> type) throws IllegalArgumentException, SQLException Sets the parameters.- Type Parameters:
T
-- Parameters:
startParameterIndex
-parameters
-type
-- Returns:
- Throws:
IllegalArgumentException
- if specifiedparameters
ortype
is null.SQLException
-
setParameters
Sets the parameters.- Parameters:
paramsSetter
-- Returns:
- Throws:
SQLException
-
setParameters
public <T> This setParameters(T parameters, Jdbc.BiParametersSetter<? super Stmt, ? super T> paramsSetter) throws SQLExceptionSets the parameters.- Type Parameters:
T
-- Parameters:
parameters
-paramsSetter
-- Returns:
- Throws:
SQLException
-
settParameters
@Beta public This settParameters(Jdbc.ParametersSetter<? super This> paramsSetter) throws SQLException - Parameters:
paramsSetter
-- Returns:
- Throws:
SQLException
-
settParameters
@Beta public <T> This settParameters(T parameters, Jdbc.BiParametersSetter<? super This, ? super T> paramsSetter) throws SQLException- Type Parameters:
T
-- Parameters:
parameters
-paramsSetter
-- Returns:
- Throws:
SQLException
-
setIntForMultiPositions
@Beta public This setIntForMultiPositions(int parameterValue, int... parameterIndices) throws SQLException - Throws:
SQLException
-
setIntegerForMultiPositions
@Beta public This setIntegerForMultiPositions(Integer parameterValue, int... parameterIndices) throws SQLException Note: The reason for giving name:setIntegerForMultiPositions
, notsetIntForMultiPositions
is because of error: The method setIntForMultiPositions(int, int[]) is ambiguous for the type- Parameters:
parameterValue
-parameterIndices
-- Returns:
- Throws:
SQLException
-
setLongForMultiPositions
@Beta public This setLongForMultiPositions(long parameterValue, int... parameterIndices) throws SQLException - Throws:
SQLException
-
setLongForMultiPositions
@Beta public This setLongForMultiPositions(Long parameterValue, int... parameterIndices) throws SQLException - Throws:
SQLException
-
setStringForMultiPositions
@Beta public This setStringForMultiPositions(String parameterValue, int... parameterIndices) throws SQLException - Throws:
SQLException
-
setDateForMultiPositions
@Beta public This setDateForMultiPositions(Date parameterValue, int... parameterIndices) throws SQLException - Throws:
SQLException
-
setDateForMultiPositions
@Beta public This setDateForMultiPositions(Date parameterValue, int... parameterIndices) throws SQLException - Throws:
SQLException
-
setTimeForMultiPositions
@Beta public This setTimeForMultiPositions(Time parameterValue, int... parameterIndices) throws SQLException - Throws:
SQLException
-
setTimeForMultiPositions
@Beta public This setTimeForMultiPositions(Date parameterValue, int... parameterIndices) throws SQLException - Throws:
SQLException
-
setTimestampForMultiPositions
@Beta public This setTimestampForMultiPositions(Timestamp parameterValue, int... parameterIndices) throws SQLException - Throws:
SQLException
-
setTimestampForMultiPositions
@Beta public This setTimestampForMultiPositions(Date parameterValue, int... parameterIndices) throws SQLException - Throws:
SQLException
-
setObjectForMultiPositions
@Beta public This setObjectForMultiPositions(Object parameterValue, int... parameterIndices) throws SQLException - Throws:
SQLException
-
addBatchParameters
@Beta public <T> This addBatchParameters(Collection<? extends T> batchParameters) throws SQLException - Type Parameters:
T
-- Parameters:
batchParameters
-- Returns:
- Throws:
SQLException
-
addBatchParameters
@Beta public <T> This addBatchParameters(Collection<? extends T> batchParameters, Class<T> type) throws SQLException - Type Parameters:
T
-- Parameters:
batchParameters
- single batch parameters.type
-- Returns:
- Throws:
SQLException
-
addBatchParameters
- Type Parameters:
T
-- Parameters:
batchParameters
-- Returns:
- Throws:
SQLException
-
addBatchParameters
@Beta public <T> This addBatchParameters(Iterator<? extends T> batchParameters, Class<T> type) throws SQLException - Type Parameters:
T
-- Parameters:
batchParameters
- single batch parameters.type
-- Returns:
- Throws:
SQLException
-
addBatchParameters
@Beta public <T> This addBatchParameters(Collection<? extends T> batchParameters, Jdbc.BiParametersSetter<? super This, ? super T> parametersSetter) throws SQLException- Type Parameters:
T
-- Parameters:
batchParameters
-parametersSetter
-- Returns:
- Throws:
SQLException
-
addBatchParameters
@Beta public <T> This addBatchParameters(Iterator<? extends T> batchParameters, Jdbc.BiParametersSetter<? super This, ? super T> parametersSetter) throws SQLException- Type Parameters:
T
-- Parameters:
batchParameters
-parametersSetter
-- Returns:
- Throws:
SQLException
-
addBatchParameters
@Beta public <T> This addBatchParameters(Collection<? extends T> batchParameters, com.landawn.abacus.util.Throwables.TriConsumer<? super This, ? super Stmt, throws SQLException? super T, ? extends SQLException> parametersSetter) - Type Parameters:
T
-- Parameters:
batchParameters
-parametersSetter
-- Returns:
- Throws:
SQLException
-
addBatchParameters
@Beta public <T> This addBatchParameters(Iterator<? extends T> batchParameters, com.landawn.abacus.util.Throwables.TriConsumer<? super This, ? super Stmt, throws SQLException? super T, ? extends SQLException> parametersSetter) - Type Parameters:
T
-- Parameters:
batchParameters
-parametersSetter
-- Returns:
- Throws:
SQLException
-
addBatch
Adds the batch.- Returns:
- Throws:
SQLException
-
setFetchDirection
Sets the fetch direction.- Parameters:
direction
- one ofResultSet.FETCH_FORWARD
,ResultSet.FETCH_REVERSE
, orResultSet.FETCH_UNKNOWN
- Returns:
- Throws:
SQLException
-
setFetchDirectionToForward
- Returns:
- Throws:
SQLException
-
setFetchSize
Sets the fetch size.- Parameters:
rows
-- Returns:
- Throws:
SQLException
-
setMaxFieldSize
Sets the max field size.- Parameters:
max
-- Returns:
- Throws:
SQLException
-
setMaxRows
Sets the max rows.- Parameters:
max
-- Returns:
- Throws:
SQLException
-
setLargeMaxRows
Sets the large max rows.- Parameters:
max
-- Returns:
- Throws:
SQLException
-
setQueryTimeout
Sets the query timeout.- Parameters:
seconds
-- Returns:
- Throws:
SQLException
-
configStmt
@Beta public This configStmt(com.landawn.abacus.util.Throwables.Consumer<? super This, ? extends SQLException> stmtSetter) throws SQLExceptionConfigure thisPreparedQuery/Statement
bystmtSetter
.final Throwables.Consumer<AbstractPreparedQuery, SQLException> commonStmtConfig = q -> q.setFetchSize(100).setQueryTimeout(60000); JdbcUtil.prepareQuery(sql).configStmt(commonStmtConfig).setParameters(parameters).list...
- Parameters:
stmtSetter
-- Returns:
- Throws:
SQLException
-
configStmt
@Beta public This configStmt(com.landawn.abacus.util.Throwables.BiConsumer<? super This, ? super Stmt, throws SQLException? extends SQLException> stmtSetter) Configure thisPreparedQuery/Statement
bystmtSetter
.final Throwables.Consumer<AbstractPreparedQuery, SQLException> commonStmtConfig = (q, stmt) -> q.setFetchSize(100).setQueryTimeout(60000); JdbcUtil.prepareQuery(sql).configStmt(commonStmtConfig).setParameters(parameters).list...
- Parameters:
stmtSetter
-- Returns:
- Throws:
SQLException
-
queryForBoolean
Query for boolean.- Returns:
- Throws:
SQLException
-
queryForChar
Query for char.- Returns:
- Throws:
SQLException
-
queryForByte
Query for byte.- Returns:
- Throws:
SQLException
-
queryForShort
Query for short.- Returns:
- Throws:
SQLException
-
queryForInt
Query for int.- Returns:
- Throws:
SQLException
-
queryForLong
Query for long.- Returns:
- Throws:
SQLException
-
queryForFloat
Query for float.- Returns:
- Throws:
SQLException
-
queryForDouble
Query for double.- Returns:
- Throws:
SQLException
-
queryForString
Query for string.- Returns:
- Throws:
SQLException
-
queryForBigInteger
@Beta public com.landawn.abacus.util.u.Nullable<BigInteger> queryForBigInteger() throws SQLExceptionQuery big integer.- Returns:
- Throws:
SQLException
-
queryForBigDecimal
@Beta public com.landawn.abacus.util.u.Nullable<BigDecimal> queryForBigDecimal() throws SQLExceptionQuery big decimal.- Returns:
- Throws:
SQLException
-
queryForDate
Query for date.- Returns:
- Throws:
SQLException
-
queryForTime
Query for time.- Returns:
- Throws:
SQLException
-
queryForTimestamp
Query for timestamp.- Returns:
- Throws:
SQLException
-
queryForSingleResult
public <V> com.landawn.abacus.util.u.Nullable<V> queryForSingleResult(Class<V> targetClass) throws SQLException Returns aNullable
describing the value in the first row/column if it exists, otherwise return an emptyNullable
.- Type Parameters:
V
- the value type- Parameters:
targetClass
-- Returns:
- Throws:
SQLException
-
queryForSingleNonNull
public <V> com.landawn.abacus.util.u.Optional<V> queryForSingleNonNull(Class<V> targetClass) throws SQLException Returns anOptional
describing the value in the first row/column if it exists, otherwise return an emptyOptional
.- Type Parameters:
V
- the value type- Parameters:
targetClass
-- Returns:
- Throws:
SQLException
-
queryForUniqueResult
public <V> com.landawn.abacus.util.u.Nullable<V> queryForUniqueResult(Class<V> targetClass) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException Returns aNullable
describing the value in the first row/column if it exists, otherwise return an emptyNullable
. And throwsDuplicatedResultException
if more than one record found.- Type Parameters:
V
- the value type- Parameters:
targetClass
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
-
queryForUniqueNonNull
public <V> com.landawn.abacus.util.u.Optional<V> queryForUniqueNonNull(Class<V> targetClass) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException Returns anOptional
describing the value in the first row/column if it exists, otherwise return an emptyOptional
. And throwsDuplicatedResultException
if more than one record found.- Type Parameters:
V
- the value type- Parameters:
targetClass
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
-
query
- Returns:
- Throws:
SQLException
-
query
- Type Parameters:
R
-- Parameters:
resultExtrator
- Don't save/returnResultSet
. It will be closed after this call.- Returns:
- Throws:
SQLException
-
query
- Type Parameters:
R
-- Parameters:
resultExtrator
- Don't save/returnResultSet
. It will be closed after this call.- Returns:
- Throws:
SQLException
-
get
@Deprecated public <T> com.landawn.abacus.util.u.Optional<T> get(Class<T> targetClass) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException Deprecated.replaced byfindOnlyOne
.- Type Parameters:
T
-- Parameters:
targetClass
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the querySQLException
-
get
@Deprecated public <T> com.landawn.abacus.util.u.Optional<T> get(Jdbc.RowMapper<T> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException Deprecated.replaced byfindOnlyOne
.- Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the querySQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
get
@Deprecated public <T> com.landawn.abacus.util.u.Optional<T> get(Jdbc.BiRowMapper<T> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException Deprecated.replaced byfindOnlyOne
.- Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the querySQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
gett
@Deprecated public <T> T gett(Class<T> targetClass) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException Deprecated.replaced byfindOnlyOneOrNull
.- Type Parameters:
T
-- Parameters:
targetClass
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the querySQLException
-
gett
@Deprecated public <T> T gett(Jdbc.RowMapper<T> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException Deprecated.replaced byfindOnlyOneOrNull
.- Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the querySQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
gett
@Deprecated public <T> T gett(Jdbc.BiRowMapper<T> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException Deprecated.replaced byfindOnlyOneOrNull
.- Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the querySQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
findOnlyOne
public com.landawn.abacus.util.u.Optional<Map<String,Object>> findOnlyOne() throws com.landawn.abacus.exception.DuplicatedResultException, SQLException- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the querySQLException
-
findOnlyOne
public <T> com.landawn.abacus.util.u.Optional<T> findOnlyOne(Class<T> targetClass) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException - Type Parameters:
T
-- Parameters:
targetClass
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the queryNullPointerException
- ifrowMapper
returnsnull
for the found record.SQLException
-
findOnlyOne
public <T> com.landawn.abacus.util.u.Optional<T> findOnlyOne(Jdbc.RowMapper<T> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException - Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the querySQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
findOnlyOne
public <T> com.landawn.abacus.util.u.Optional<T> findOnlyOne(Jdbc.BiRowMapper<T> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException - Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the querySQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
findOnlyOneOrNull
public Map<String,Object> findOnlyOneOrNull() throws com.landawn.abacus.exception.DuplicatedResultException, SQLException- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the querySQLException
-
findOnlyOneOrNull
public <T> T findOnlyOneOrNull(Class<T> targetClass) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException - Type Parameters:
T
-- Parameters:
targetClass
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the querySQLException
-
findOnlyOneOrNull
public <T> T findOnlyOneOrNull(Jdbc.RowMapper<T> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException - Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the querySQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
findOnlyOneOrNull
public <T> T findOnlyOneOrNull(Jdbc.BiRowMapper<T> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException - Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- If More than one record found by the querySQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
findFirst
- Returns:
- Throws:
SQLException
-
findFirst
public <T> com.landawn.abacus.util.u.Optional<T> findFirst(Class<T> targetClass) throws SQLException - Type Parameters:
T
-- Parameters:
targetClass
-- Returns:
- Throws:
SQLException
-
findFirst
public <T> com.landawn.abacus.util.u.Optional<T> findFirst(Jdbc.RowMapper<T> rowMapper) throws SQLException, NullPointerException - Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
findFirst
@Deprecated public <T> com.landawn.abacus.util.u.Optional<T> findFirst(Jdbc.RowFilter rowFilter, Jdbc.RowMapper<T> rowMapper) throws SQLException, NullPointerException Deprecated.Use {@link stream(RowFilter, RowMapper).first()} instead.- Type Parameters:
T
-- Parameters:
rowFilter
-rowMapper
-- Returns:
- Throws:
SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
findFirst
public <T> com.landawn.abacus.util.u.Optional<T> findFirst(Jdbc.BiRowMapper<T> rowMapper) throws SQLException, NullPointerException - Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
findFirst
@Deprecated public <T> com.landawn.abacus.util.u.Optional<T> findFirst(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<T> rowMapper) throws SQLException, NullPointerException Deprecated.Use {@link stream(BiRowFilter, BiRowMapper).first()} instead.- Type Parameters:
T
-- Parameters:
rowFilter
-rowMapper
-- Returns:
- Throws:
SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
findFirstOrNull
- Returns:
- Throws:
SQLException
-
findFirstOrNull
- Type Parameters:
T
-- Parameters:
targetClass
-- Returns:
- Throws:
SQLException
-
findFirstOrNull
- Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
findFirstOrNull
@Deprecated public <T> T findFirstOrNull(Jdbc.RowFilter rowFilter, Jdbc.RowMapper<T> rowMapper) throws SQLException, NullPointerException Deprecated.Use {@link stream(RowFilter, RowMapper).first()} instead.- Type Parameters:
T
-- Parameters:
rowFilter
-rowMapper
-- Returns:
- Throws:
SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
findFirstOrNull
public <T> T findFirstOrNull(Jdbc.BiRowMapper<T> rowMapper) throws SQLException, NullPointerException - Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
findFirstOrNull
@Deprecated public <T> T findFirstOrNull(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<T> rowMapper) throws SQLException, NullPointerException Deprecated.Use {@link stream(BiRowFilter, BiRowMapper).first()} instead.- Type Parameters:
T
-- Parameters:
rowFilter
-rowMapper
-- Returns:
- Throws:
SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
list
- Returns:
- Throws:
SQLException
-
list
- Type Parameters:
T
-- Parameters:
targetClass
-- Returns:
- Throws:
SQLException
-
list
Deprecated.the result size should be limited in database server side by sql scripts.- Type Parameters:
T
-- Parameters:
targetClass
-maxResult
-- Returns:
- Throws:
SQLException
-
list
- Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
SQLException
-
list
Deprecated.the result size should be limited in database server side by sql scripts.- Type Parameters:
T
-- Parameters:
rowMapper
-maxResult
-- Returns:
- Throws:
SQLException
-
list
- Type Parameters:
T
-- Parameters:
rowFilter
-rowMapper
-- Returns:
- Throws:
SQLException
-
list
public <T> List<T> list(Jdbc.RowFilter rowFilter, Jdbc.RowMapper<T> rowMapper, int maxResult) throws SQLException - Type Parameters:
T
-- Parameters:
rowFilter
-rowMapper
-maxResult
-- Returns:
- Throws:
SQLException
-
list
- Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- Throws:
SQLException
-
list
@Deprecated public <T> List<T> list(Jdbc.BiRowMapper<T> rowMapper, int maxResult) throws SQLException Deprecated.the result size should be limited in database server side by sql scripts.- Type Parameters:
T
-- Parameters:
rowMapper
-maxResult
-- Returns:
- Throws:
SQLException
-
list
public <T> List<T> list(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<T> rowMapper) throws SQLException - Type Parameters:
T
-- Parameters:
rowFilter
-rowMapper
-- Returns:
- Throws:
SQLException
-
list
public <T> List<T> list(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<T> rowMapper, int maxResult) throws SQLException - Type Parameters:
T
-- Parameters:
rowFilter
-rowMapper
-maxResult
-- Returns:
- Throws:
SQLException
-
stream
lazy-execution, lazy-fetch.
Note: The openedConnection
andStatement
will be held on till@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Returns:
- See Also:
-
stream
lazy-execution, lazy-fetch.
Note: The openedConnection
andStatement
will be held on till@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Type Parameters:
T
-- Parameters:
targetClass
-- Returns:
- See Also:
-
stream
public <T> com.landawn.abacus.util.ExceptionalStream<T,SQLException> stream(Jdbc.RowMapper<T> rowMapper) lazy-execution, lazy-fetch.
Note: The openedConnection
andStatement
will be held on till@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- See Also:
-
stream
public <T> com.landawn.abacus.util.ExceptionalStream<T,SQLException> stream(Jdbc.BiRowMapper<T> rowMapper) lazy-execution, lazy-fetch.
Note: The openedConnection
andStatement
will be held on till@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Type Parameters:
T
-- Parameters:
rowMapper
-- Returns:
- See Also:
-
stream
public <T> com.landawn.abacus.util.ExceptionalStream<T,SQLException> stream(Jdbc.RowFilter rowFilter, Jdbc.RowMapper<T> rowMapper) lazy-execution, lazy-fetch.
Note: The openedConnection
andStatement
will be held on till@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Type Parameters:
T
-- Parameters:
rowFilter
-rowMapper
-- Returns:
- See Also:
-
stream
public <T> com.landawn.abacus.util.ExceptionalStream<T,SQLException> stream(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<T> rowMapper) lazy-execution, lazy-fetch.
Note: The openedConnection
andStatement
will be held on till@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Type Parameters:
T
-- Parameters:
rowFilter
-rowMapper
-- Returns:
- See Also:
-
exists
Note: usingselect 1 from ...
, notselect count(*) from ...
.- Returns:
- true, if there is at least one record found.
- Throws:
SQLException
-
notExists
Why addingnotExists()
? not justexists() == false
or!exists()
? BecausenotExists()
is not minor case. It's a general case.not exists
is better expression thanexists() == false
or!exists()
.
Note: usingselect 1 from ...
, notselect count(*) from ...
.- Returns:
- true, if there is no record found.
- Throws:
SQLException
- See Also:
-
ifExists
- Parameters:
rowConsumer
-- Throws:
SQLException
-
ifExists
- Parameters:
rowConsumer
-- Throws:
SQLException
-
ifExistsOrElse
public void ifExistsOrElse(Jdbc.RowConsumer rowConsumer, com.landawn.abacus.util.Throwables.Runnable<SQLException> orElseAction) throws SQLException If exists or else.- Parameters:
rowConsumer
-orElseAction
-- Throws:
SQLException
-
ifExistsOrElse
public void ifExistsOrElse(Jdbc.BiRowConsumer rowConsumer, com.landawn.abacus.util.Throwables.Runnable<SQLException> orElseAction) throws SQLException If exists or else.- Parameters:
rowConsumer
-orElseAction
-- Throws:
SQLException
-
count
Deprecated.may be misused and it's inefficient.UsesqueryForInt()
with queryselect count(*) from ...
- Returns:
- Throws:
SQLException
- See Also:
-
count
- Parameters:
rowFilter
-- Returns:
- Throws:
SQLException
-
count
- Parameters:
rowFilter
-- Returns:
- Throws:
SQLException
-
anyMatch
- Parameters:
rowFilter
-- Returns:
- true, if successful
- Throws:
SQLException
-
anyMatch
- Parameters:
rowFilter
-- Returns:
- true, if successful
- Throws:
SQLException
-
allMatch
- Parameters:
rowFilter
-- Returns:
- true, if successful
- Throws:
SQLException
-
allMatch
- Parameters:
rowFilter
-- Returns:
- true, if successful
- Throws:
SQLException
-
noneMatch
- Parameters:
rowFilter
-- Returns:
- true, if successful
- Throws:
SQLException
-
noneMatch
- Parameters:
rowFilter
-- Returns:
- true, if successful
- Throws:
SQLException
-
forEach
- Parameters:
rowConsumer
-- Throws:
SQLException
-
forEach
- Parameters:
rowFilter
-rowConsumer
-- Throws:
SQLException
-
forEach
- Parameters:
rowConsumer
-- Throws:
SQLException
-
forEach
- Parameters:
rowFilter
-rowConsumer
-- Throws:
SQLException
-
foreach
@Beta public void foreach(Consumer<com.landawn.abacus.util.NoCachingNoUpdating.DisposableObjArray> rowConsumer) throws SQLException - Parameters:
rowConsumer
-- Throws:
SQLException
-
foreach
@Beta public void foreach(Class<?> entityClass, Consumer<com.landawn.abacus.util.NoCachingNoUpdating.DisposableObjArray> rowConsumer) throws SQLException - Parameters:
entityClass
- used to fetch column/row value fromResultSet
by the type of fields/columns defined in this class.rowConsumer
-- Throws:
SQLException
-
insert
Returns the generated key if it exists.- Type Parameters:
ID
-- Returns:
- Throws:
SQLException
-
insert
public <ID> com.landawn.abacus.util.u.Optional<ID> insert(Jdbc.RowMapper<ID> autoGeneratedKeyExtractor) throws SQLException - Type Parameters:
ID
-- Parameters:
autoGeneratedKeyExtractor
-- Returns:
- Throws:
SQLException
-
insert
public <ID> com.landawn.abacus.util.u.Optional<ID> insert(Jdbc.BiRowMapper<ID> autoGeneratedKeyExtractor) throws SQLException - Type Parameters:
ID
-- Parameters:
autoGeneratedKeyExtractor
-- Returns:
- Throws:
SQLException
-
batchInsert
Returns the generated key if it exists.- Type Parameters:
ID
-- Returns:
- Throws:
SQLException
-
batchInsert
- Type Parameters:
ID
-- Parameters:
autoGeneratedKeyExtractor
-- Returns:
- Throws:
SQLException
-
batchInsert
public <ID> List<ID> batchInsert(Jdbc.BiRowMapper<ID> autoGeneratedKeyExtractor) throws SQLException - Type Parameters:
ID
-- Parameters:
autoGeneratedKeyExtractor
-- Returns:
- Throws:
SQLException
-
update
- Returns:
- Throws:
SQLException
-
updateAndReturnGeneratedKeys
public <T> com.landawn.abacus.util.Tuple.Tuple2<Integer,List<T>> updateAndReturnGeneratedKeys(Jdbc.RowMapper<T> autoGeneratedKeyExtractor) throws SQLException - Returns:
- Throws:
SQLException
-
updateAndReturnGeneratedKeys
public <T> com.landawn.abacus.util.Tuple.Tuple2<Integer,List<T>> updateAndReturnGeneratedKeys(Jdbc.BiRowMapper<T> autoGeneratedKeyExtractor) throws SQLException - Returns:
- Throws:
SQLException
-
batchUpdate
- Returns:
- Throws:
SQLException
-
batchUpdateAndReturnGeneratedKeys
public <T> com.landawn.abacus.util.Tuple.Tuple2<int[],List<T>> batchUpdateAndReturnGeneratedKeys(Jdbc.RowMapper<T> autoGeneratedKeyExtractor) throws SQLException - Returns:
- Throws:
SQLException
-
batchUpdateAndReturnGeneratedKeys
public <T> com.landawn.abacus.util.Tuple.Tuple2<int[],List<T>> batchUpdateAndReturnGeneratedKeys(Jdbc.BiRowMapper<T> autoGeneratedKeyExtractor) throws SQLException - Returns:
- Throws:
SQLException
-
largeUpdate
- Returns:
- Throws:
SQLException
-
largeBatchUpdate
Large batch update.- Returns:
- Throws:
SQLException
-
execute
- Returns:
- true, if successful
- Throws:
SQLException
-
executeThenApply
public <R> R executeThenApply(com.landawn.abacus.util.Throwables.Function<? super Stmt, ? extends R, throws SQLExceptionSQLException> getter) Execute then apply.- Type Parameters:
R
-- Parameters:
getter
-- Returns:
- Throws:
SQLException
-
executeThenApply
public <R> R executeThenApply(com.landawn.abacus.util.Throwables.BiFunction<Boolean, ? super Stmt, throws SQLException? extends R, SQLException> getter) Execute then apply.- Type Parameters:
R
-- Parameters:
getter
-- Returns:
- Throws:
SQLException
-
executeThenAccept
public void executeThenAccept(com.landawn.abacus.util.Throwables.Consumer<? super Stmt, SQLException> consumer) throws SQLExceptionExecute then accept.- Parameters:
consumer
-- Throws:
SQLException
-
executeThenAccept
public void executeThenAccept(com.landawn.abacus.util.Throwables.BiConsumer<Boolean, ? super Stmt, throws SQLExceptionSQLException> consumer) Execute then accept.- Parameters:
consumer
-- Throws:
SQLException
-
asyncCall
@Beta public <R> com.landawn.abacus.util.ContinuableFuture<R> asyncCall(com.landawn.abacus.util.Throwables.Function<This, R, SQLException> sqlAction) Note: The openedConnection
andStatement
will be held on tillsqlAction
is completed by another thread.- Type Parameters:
R
-- Parameters:
sqlAction
-- Returns:
-
asyncCall
@Beta public <R> com.landawn.abacus.util.ContinuableFuture<R> asyncCall(com.landawn.abacus.util.Throwables.Function<This, R, SQLException> sqlAction, Executor executor) Note: The openedConnection
andStatement
will be held on tillsqlAction
is completed by another thread.- Type Parameters:
R
-- Parameters:
sqlAction
-executor
-- Returns:
-
asyncRun
@Beta public com.landawn.abacus.util.ContinuableFuture<Void> asyncRun(com.landawn.abacus.util.Throwables.Consumer<This, SQLException> sqlAction) Note: The openedConnection
andStatement
will be held on tillsqlAction
is completed by another thread.- Parameters:
sqlAction
-- Returns:
-
asyncRun
@Beta public com.landawn.abacus.util.ContinuableFuture<Void> asyncRun(com.landawn.abacus.util.Throwables.Consumer<This, SQLException> sqlAction, Executor executor) Note: The openedConnection
andStatement
will be held on tillsqlAction
is completed by another thread.- Parameters:
sqlAction
-executor
-- Returns:
-
close
public void close()Close.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-