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 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 Details

      • closeAfterExecution

        public This closeAfterExecution(boolean closeAfterExecution)
        Parameters:
        closeAfterExecution - default is true.
        Returns:
      • onClose

        public This onClose(Runnable closeHandler)
        Parameters:
        closeHandler - A task to execute after this Query is closed
        Returns:
      • setNull

        public This setNull(int parameterIndex, int sqlType) throws SQLException
        Sets the null.
        Parameters:
        parameterIndex - starts from 1, not 0.
        sqlType -
        Returns:
        Throws:
        SQLException
        See Also:
      • setNull

        public This setNull(int parameterIndex, int sqlType, String typeName) throws SQLException
        Sets the null.
        Parameters:
        parameterIndex - starts from 1, not 0.
        sqlType -
        typeName -
        Returns:
        Throws:
        SQLException
        See Also:
      • setBoolean

        public This setBoolean(int parameterIndex, boolean x) throws SQLException
        Sets the boolean.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setBoolean

        public This setBoolean(int parameterIndex, Boolean x) throws SQLException
        Sets the boolean.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setByte

        public This setByte(int parameterIndex, byte x) throws SQLException
        Sets the byte.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setByte

        public This setByte(int parameterIndex, Byte x) throws SQLException
        Sets the byte.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setShort

        public This setShort(int parameterIndex, short x) throws SQLException
        Sets the short.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setShort

        public This setShort(int parameterIndex, Short x) throws SQLException
        Sets the short.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setInt

        public This setInt(int parameterIndex, int x) throws SQLException
        Sets the int.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setInt

        public This setInt(int parameterIndex, Integer x) throws SQLException
        Sets the int.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setInt

        @Deprecated @Beta public This setInt(int parameterIndex, char x) throws SQLException
        Deprecated.
        generally char should be saved as String in db.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
        See Also:
      • setInt

        @Deprecated @Beta public This setInt(int parameterIndex, Character x) throws SQLException
        Deprecated.
        generally char should be saved as String in db.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
        See Also:
      • setLong

        public This setLong(int parameterIndex, long x) throws SQLException
        Sets the long.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setLong

        public This setLong(int parameterIndex, Long x) throws SQLException
        Sets the long.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setFloat

        public This setFloat(int parameterIndex, float x) throws SQLException
        Sets the float.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setFloat

        public This setFloat(int parameterIndex, Float x) throws SQLException
        Sets the float.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setDouble

        public This setDouble(int parameterIndex, double x) throws SQLException
        Sets the double.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setDouble

        public This setDouble(int parameterIndex, Double x) throws SQLException
        Sets the double.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setBigDecimal

        public This setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException
        Sets the big decimal.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setString

        public This setString(int parameterIndex, String x) throws SQLException
        Sets the string.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setString

        public This setString(int parameterIndex, CharSequence x) throws SQLException
        Sets the string.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setString

        public This setString(int parameterIndex, char x) throws SQLException
        Throws:
        SQLException
      • setString

        public This setString(int parameterIndex, Character x) throws SQLException
        Sets the String.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setDate

        public This setDate(int parameterIndex, Date x) throws SQLException
        Sets the date.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setDate

        public This setDate(int parameterIndex, Date x) throws SQLException
        Sets the date.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setTime

        public This setTime(int parameterIndex, Time x) throws SQLException
        Sets the time.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setTime

        public This setTime(int parameterIndex, Date x) throws SQLException
        Sets the time.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setTimestamp

        public This setTimestamp(int parameterIndex, Timestamp x) throws SQLException
        Sets the timestamp.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setTimestamp

        public This setTimestamp(int parameterIndex, Date x) throws SQLException
        Sets the timestamp.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setBytes

        public This setBytes(int parameterIndex, byte[] x) throws SQLException
        Sets the bytes.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setAsciiStream

        public This setAsciiStream(int parameterIndex, InputStream inputStream) throws SQLException
        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

        public This setBinaryStream(int parameterIndex, InputStream inputStream) throws SQLException
        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

        public This setCharacterStream(int parameterIndex, Reader reader) throws SQLException
        Sets the character stream.
        Parameters:
        parameterIndex -
        reader -
        Returns:
        Throws:
        SQLException
      • setCharacterStream

        public This setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException
        Sets the character stream.
        Parameters:
        parameterIndex -
        reader -
        length -
        Returns:
        Throws:
        SQLException
      • setNCharacterStream

        public This setNCharacterStream(int parameterIndex, Reader reader) throws SQLException
        Sets the N character stream.
        Parameters:
        parameterIndex -
        reader -
        Returns:
        Throws:
        SQLException
      • setNCharacterStream

        public This setNCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException
        Sets the N character stream.
        Parameters:
        parameterIndex -
        reader -
        length -
        Returns:
        Throws:
        SQLException
      • setBlob

        public This setBlob(int parameterIndex, Blob x) throws SQLException
        Sets the blob.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setBlob

        public This setBlob(int parameterIndex, InputStream inputStream) throws SQLException
        Sets the blob.
        Parameters:
        parameterIndex -
        inputStream -
        Returns:
        Throws:
        SQLException
      • setBlob

        public This setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException
        Sets the blob.
        Parameters:
        parameterIndex -
        inputStream -
        length -
        Returns:
        Throws:
        SQLException
      • setClob

        public This setClob(int parameterIndex, Clob x) throws SQLException
        Sets the clob.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setClob

        public This setClob(int parameterIndex, Reader reader) throws SQLException
        Sets the clob.
        Parameters:
        parameterIndex -
        reader -
        Returns:
        Throws:
        SQLException
      • setClob

        public This setClob(int parameterIndex, Reader reader, long length) throws SQLException
        Sets the clob.
        Parameters:
        parameterIndex -
        reader -
        length -
        Returns:
        Throws:
        SQLException
      • setNClob

        public This setNClob(int parameterIndex, NClob x) throws SQLException
        Sets the N clob.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setNClob

        public This setNClob(int parameterIndex, Reader reader) throws SQLException
        Sets the N clob.
        Parameters:
        parameterIndex -
        reader -
        Returns:
        Throws:
        SQLException
      • setNClob

        public This setNClob(int parameterIndex, Reader reader, long length) throws SQLException
        Sets the N clob.
        Parameters:
        parameterIndex -
        reader -
        length -
        Returns:
        Throws:
        SQLException
      • setURL

        public This setURL(int parameterIndex, URL x) throws SQLException
        Sets the URL.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setArray

        public This setArray(int parameterIndex, Array x) throws SQLException
        Sets the array.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setSQLXML

        public This setSQLXML(int parameterIndex, SQLXML x) throws SQLException
        Sets the SQLXML.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setRef

        public This setRef(int parameterIndex, Ref x) throws SQLException
        Sets the ref.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setRowId

        public This setRowId(int parameterIndex, RowId x) throws SQLException
        Sets the row id.
        Parameters:
        parameterIndex -
        x -
        Returns:
        Throws:
        SQLException
      • setObject

        public This setObject(int parameterIndex, Object x) throws SQLException
        Sets the object.
        Parameters:
        parameterIndex - starts from 1, not 0.
        x -
        Returns:
        Throws:
        SQLException
      • setObject

        public This setObject(int parameterIndex, Object x, int sqlType) throws SQLException
        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

        public This setObject(int parameterIndex, Object x, SQLType sqlType) throws SQLException
        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
      • setParameters

        public This setParameters(String param1, String param2) throws SQLException
        Sets the parameters.
        Parameters:
        param1 -
        param2 -
        Returns:
        Throws:
        SQLException
      • setParameters

        public This setParameters(String param1, String param2, String param3) throws SQLException
        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

        public This setParameters(Object param1, Object param2, Object param3) throws SQLException
        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

        public This setParameters(int[] parameters) throws IllegalArgumentException, SQLException
        Sets the parameters.
        Parameters:
        parameters -
        Returns:
        Throws:
        IllegalArgumentException - if specified parameters or type is null.
        SQLException
      • setParameters

        public This setParameters(long[] parameters) throws IllegalArgumentException, SQLException
        Sets the parameters.
        Parameters:
        parameters -
        Returns:
        Throws:
        IllegalArgumentException - if specified parameters or type is null.
        SQLException
      • setParameters

        public This setParameters(String[] parameters) throws IllegalArgumentException, SQLException
        Sets the parameters.
        Parameters:
        parameters -
        Returns:
        Throws:
        IllegalArgumentException - if specified parameters or type is null.
        SQLException
      • setParameters

        public <T> This setParameters(T[] parameters) throws IllegalArgumentException, SQLException
        Sets the parameters.
        Parameters:
        parameters - it should be an array of concrete types. For example: String[], Date[].
        Returns:
        Throws:
        IllegalArgumentException - if specified parameters or type is null.
        SQLException
      • setParameters

        public This setParameters(Collection<?> parameters) throws IllegalArgumentException, SQLException
        Sets the parameters.
        Parameters:
        startParameterIndex -
        parameters -
        Returns:
        Throws:
        IllegalArgumentException - if specified parameters.
        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 specified parameters or type is null.
        SQLException
      • setParameters

        public This setParameters(Jdbc.ParametersSetter<? super Stmt> paramsSetter) throws SQLException
        Sets the parameters.
        Parameters:
        paramsSetter -
        Returns:
        Throws:
        SQLException
      • setParameters

        public <T> This setParameters(T parameters, Jdbc.BiParametersSetter<? super Stmt,? super T> paramsSetter) throws SQLException
        Sets the parameters.
        Type Parameters:
        T -
        Parameters:
        parameters -
        paramsSetter -
        Returns:
        Throws:
        SQLException
      • settParameters

        public This settParameters(int startParameterIndex, int[] parameters) throws IllegalArgumentException, SQLException
        Sets the parameters.
        Parameters:
        startParameterIndex -
        parameters -
        Returns:
        Throws:
        IllegalArgumentException - if specified parameters or type is null.
        SQLException
      • settParameters

        public This settParameters(int startParameterIndex, long[] parameters) throws IllegalArgumentException, SQLException
        Sets the parameters.
        Parameters:
        startParameterIndex -
        parameters -
        Returns:
        Throws:
        IllegalArgumentException - if specified parameters or type is null.
        SQLException
      • settParameters

        public This settParameters(int startParameterIndex, String[] parameters) throws IllegalArgumentException, SQLException
        Sets the parameters.
        Parameters:
        startParameterIndex -
        parameters -
        Returns:
        Throws:
        IllegalArgumentException - if specified parameters or type 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 specified parameters or type 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 specified parameters or type 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 specified parameters or type is null.
        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, not setIntForMultiPositions 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
      • setDoubleForMultiPositions

        @Beta public This setDoubleForMultiPositions(double parameterValue, int... parameterIndices) throws SQLException
        Throws:
        SQLException
      • setDoubleForMultiPositions

        @Beta public This setDoubleForMultiPositions(Double 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

        @Beta public <T> This addBatchParameters(Iterator<? extends T> batchParameters) throws SQLException
        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,? super T,? extends SQLException> parametersSetter) throws SQLException
        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,? super T,? extends SQLException> parametersSetter) throws SQLException
        Type Parameters:
        T -
        Parameters:
        batchParameters -
        parametersSetter -
        Returns:
        Throws:
        SQLException
      • addBatch

        public This addBatch() throws SQLException
        Adds the batch.
        Returns:
        Throws:
        SQLException
      • setFetchDirection

        public This setFetchDirection(FetchDirection direction) throws SQLException
        Sets the fetch direction.
        Parameters:
        direction - one of ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, or ResultSet.FETCH_UNKNOWN
        Returns:
        Throws:
        SQLException
      • setFetchDirectionToForward

        public This setFetchDirectionToForward() throws SQLException
        Returns:
        Throws:
        SQLException
      • setFetchSize

        public This setFetchSize(int fetchSize) throws SQLException
        Sets the fetch size.
        Parameters:
        fetchSize - the number of rows to fetch
        Returns:
        Throws:
        SQLException
      • setMaxFieldSize

        public This setMaxFieldSize(int max) throws SQLException
        Sets the max field size.
        Parameters:
        max -
        Returns:
        Throws:
        SQLException
      • setMaxRows

        public This setMaxRows(int max) throws SQLException
        Sets the max rows.
        Parameters:
        max -
        Returns:
        Throws:
        SQLException
      • setLargeMaxRows

        public This setLargeMaxRows(long max) throws SQLException
        Sets the large max rows.
        Parameters:
        max -
        Returns:
        Throws:
        SQLException
      • setQueryTimeout

        public This setQueryTimeout(int seconds) throws SQLException
        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 SQLException
        Configure this PreparedQuery/Statement by stmtSetter.
         
         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,? extends SQLException> stmtSetter) throws SQLException
        Configure this PreparedQuery/Statement by stmtSetter.
         
         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

        public com.landawn.abacus.util.u.OptionalBoolean queryForBoolean() throws SQLException
        Query for boolean.
        Returns:
        Throws:
        SQLException
      • queryForChar

        public com.landawn.abacus.util.u.OptionalChar queryForChar() throws SQLException
        Query for char.
        Returns:
        Throws:
        SQLException
      • queryForByte

        public com.landawn.abacus.util.u.OptionalByte queryForByte() throws SQLException
        Query for byte.
        Returns:
        Throws:
        SQLException
      • queryForShort

        public com.landawn.abacus.util.u.OptionalShort queryForShort() throws SQLException
        Query for short.
        Returns:
        Throws:
        SQLException
      • queryForInt

        public com.landawn.abacus.util.u.OptionalInt queryForInt() throws SQLException
        Query for int.
        Returns:
        Throws:
        SQLException
      • queryForLong

        public com.landawn.abacus.util.u.OptionalLong queryForLong() throws SQLException
        Query for long.
        Returns:
        Throws:
        SQLException
      • queryForFloat

        public com.landawn.abacus.util.u.OptionalFloat queryForFloat() throws SQLException
        Query for float.
        Returns:
        Throws:
        SQLException
      • queryForDouble

        public com.landawn.abacus.util.u.OptionalDouble queryForDouble() throws SQLException
        Query for double.
        Returns:
        Throws:
        SQLException
      • queryForString

        public com.landawn.abacus.util.u.Nullable<String> queryForString() throws SQLException
        Query for string.
        Returns:
        Throws:
        SQLException
      • queryForBigInteger

        @Beta public com.landawn.abacus.util.u.Nullable<BigInteger> queryForBigInteger() throws SQLException
        Query big integer.
        Returns:
        Throws:
        SQLException
      • queryForBigDecimal

        @Beta public com.landawn.abacus.util.u.Nullable<BigDecimal> queryForBigDecimal() throws SQLException
        Query big decimal.
        Returns:
        Throws:
        SQLException
      • queryForDate

        public com.landawn.abacus.util.u.Nullable<Date> queryForDate() throws SQLException
        Query for date.
        Returns:
        Throws:
        SQLException
      • queryForTime

        public com.landawn.abacus.util.u.Nullable<Time> queryForTime() throws SQLException
        Query for time.
        Returns:
        Throws:
        SQLException
      • queryForTimestamp

        public com.landawn.abacus.util.u.Nullable<Timestamp> queryForTimestamp() throws SQLException
        Query for timestamp.
        Returns:
        Throws:
        SQLException
      • queryForBytes

        public com.landawn.abacus.util.u.Nullable<byte[]> queryForBytes() throws SQLException
        Query for byte[].
        Returns:
        Throws:
        SQLException
      • queryForSingleResult

        public <V> com.landawn.abacus.util.u.Nullable<V> queryForSingleResult(Class<? extends V> targetType) throws SQLException
        Returns a Nullable describing the value in the first row/column if it exists, otherwise return an empty Nullable.
        Type Parameters:
        V - the value type
        Parameters:
        targetType -
        Returns:
        Throws:
        SQLException
      • queryForSingleResult

        public <V> com.landawn.abacus.util.u.Nullable<V> queryForSingleResult(com.landawn.abacus.type.Type<? extends V> targetType) throws SQLException
        Returns a Nullable describing the value in the first row/column if it exists, otherwise return an empty Nullable.
        Type Parameters:
        V -
        Parameters:
        targetType -
        Returns:
        Throws:
        SQLException
      • queryForSingleNonNull

        public <V> com.landawn.abacus.util.u.Optional<V> queryForSingleNonNull(Class<? extends V> targetType) throws SQLException
        Returns an Optional describing the value in the first row/column if it exists, otherwise return an empty Optional.
        Type Parameters:
        V - the value type
        Parameters:
        targetType -
        Returns:
        Throws:
        SQLException
      • queryForSingleNonNull

        public <V> com.landawn.abacus.util.u.Optional<V> queryForSingleNonNull(com.landawn.abacus.type.Type<? extends V> targetType) throws SQLException
        Returns an Optional describing the value in the first row/column if it exists, otherwise return an empty Optional.
        Type Parameters:
        V -
        Parameters:
        targetType -
        Returns:
        Throws:
        SQLException
      • queryForUniqueResult

        public <V> com.landawn.abacus.util.u.Nullable<V> queryForUniqueResult(Class<? extends V> targetType) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
        Returns a Nullable describing the value in the first row/column if it exists, otherwise return an empty Nullable. And throws DuplicatedResultException if more than one record found.
        Type Parameters:
        V - the value type
        Parameters:
        targetType -
        Returns:
        Throws:
        com.landawn.abacus.exception.DuplicatedResultException - if more than one record found by the specified id (or condition).
        SQLException
      • queryForUniqueResult

        public <V> com.landawn.abacus.util.u.Nullable<V> queryForUniqueResult(com.landawn.abacus.type.Type<? extends V> targetType) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
        Returns a Nullable describing the value in the first row/column if it exists, otherwise return an empty Nullable. And throws DuplicatedResultException if more than one record found.
        Type Parameters:
        V -
        Parameters:
        targetType -
        Returns:
        Throws:
        com.landawn.abacus.exception.DuplicatedResultException - if more than one record found by the specified id (or condition).
        SQLException
      • queryForUniqueNonNull

        public <V> com.landawn.abacus.util.u.Optional<V> queryForUniqueNonNull(Class<? extends V> targetType) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
        Returns an Optional describing the value in the first row/column if it exists, otherwise return an empty Optional. And throws DuplicatedResultException if more than one record found.
        Type Parameters:
        V - the value type
        Parameters:
        targetType -
        Returns:
        Throws:
        com.landawn.abacus.exception.DuplicatedResultException - if more than one record found by the specified id (or condition).
        SQLException
      • queryForUniqueNonNull

        public <V> com.landawn.abacus.util.u.Optional<V> queryForUniqueNonNull(com.landawn.abacus.type.Type<? extends V> targetType) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
        Returns an Optional describing the value in the first row/column if it exists, otherwise return an empty Optional. And throws DuplicatedResultException if more than one record found.
        Type Parameters:
        V - the value type
        Parameters:
        targetType -
        Returns:
        Throws:
        com.landawn.abacus.exception.DuplicatedResultException - if more than one record found by the specified id (or condition).
        SQLException
      • query

        public com.landawn.abacus.util.DataSet query() throws SQLException
        Returns:
        Throws:
        SQLException
      • query

        public <R> R query(Jdbc.ResultExtractor<? extends R> resultExtractor) throws SQLException
        Type Parameters:
        R -
        Parameters:
        resultExtractor - Don't save/return ResultSet. It will be closed after this call.
        Returns:
        Throws:
        SQLException
      • query

        public <R> R query(Jdbc.BiResultExtractor<? extends R> resultExtractor) throws SQLException
        Type Parameters:
        R -
        Parameters:
        resultExtractor - Don't save/return ResultSet. It will be closed after this call.
        Returns:
        Throws:
        SQLException
      • get

        @Deprecated public <T> com.landawn.abacus.util.u.Optional<T> get(Class<? extends T> targetType) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
        Deprecated.
        replaced by findOnlyOne.
        Type Parameters:
        T -
        Parameters:
        targetType -
        Returns:
        Throws:
        com.landawn.abacus.exception.DuplicatedResultException - If More than one record found by the query
        SQLException
      • get

        @Deprecated public <T> com.landawn.abacus.util.u.Optional<T> get(Jdbc.RowMapper<? extends T> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException
        Deprecated.
        replaced by findOnlyOne.
        Type Parameters:
        T -
        Parameters:
        rowMapper -
        Returns:
        Throws:
        com.landawn.abacus.exception.DuplicatedResultException - If More than one record found by the query
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • get

        @Deprecated public <T> com.landawn.abacus.util.u.Optional<T> get(Jdbc.BiRowMapper<? extends T> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException
        Deprecated.
        replaced by findOnlyOne.
        Type Parameters:
        T -
        Parameters:
        rowMapper -
        Returns:
        Throws:
        com.landawn.abacus.exception.DuplicatedResultException - If More than one record found by the query
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • gett

        @Deprecated public <T> T gett(Class<? extends T> targetType) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
        Deprecated.
        replaced by findOnlyOneOrNull.
        Type Parameters:
        T -
        Parameters:
        targetType -
        Returns:
        Throws:
        com.landawn.abacus.exception.DuplicatedResultException - If More than one record found by the query
        SQLException
      • gett

        @Deprecated public <T> T gett(Jdbc.RowMapper<? extends T> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException
        Deprecated.
        replaced by findOnlyOneOrNull.
        Type Parameters:
        T -
        Parameters:
        rowMapper -
        Returns:
        Throws:
        com.landawn.abacus.exception.DuplicatedResultException - If More than one record found by the query
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • gett

        @Deprecated public <T> T gett(Jdbc.BiRowMapper<? extends T> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException
        Deprecated.
        replaced by findOnlyOneOrNull.
        Type Parameters:
        T -
        Parameters:
        rowMapper -
        Returns:
        Throws:
        com.landawn.abacus.exception.DuplicatedResultException - If More than one record found by the query
        SQLException
        NullPointerException - if rowMapper returns null 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 query
        SQLException
      • findOnlyOne

        public <T> com.landawn.abacus.util.u.Optional<T> findOnlyOne(Class<? extends T> targetType) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
        Type Parameters:
        T -
        Parameters:
        targetType -
        Returns:
        Throws:
        com.landawn.abacus.exception.DuplicatedResultException - If More than one record found by the query
        NullPointerException - if rowMapper returns null for the found record.
        SQLException
      • findOnlyOne

        public <T> com.landawn.abacus.util.u.Optional<T> findOnlyOne(Jdbc.RowMapper<? extends 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 query
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • findOnlyOne

        public <T> com.landawn.abacus.util.u.Optional<T> findOnlyOne(Jdbc.BiRowMapper<? extends 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 query
        SQLException
        NullPointerException - if rowMapper returns null 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 query
        SQLException
      • findOnlyOneOrNull

        public <T> T findOnlyOneOrNull(Class<? extends T> targetType) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
        Type Parameters:
        T -
        Parameters:
        targetType -
        Returns:
        Throws:
        com.landawn.abacus.exception.DuplicatedResultException - If More than one record found by the query
        SQLException
      • findOnlyOneOrNull

        public <T> T findOnlyOneOrNull(Jdbc.RowMapper<? extends 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 query
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • findOnlyOneOrNull

        public <T> T findOnlyOneOrNull(Jdbc.BiRowMapper<? extends 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 query
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • findFirst

        public com.landawn.abacus.util.u.Optional<Map<String,Object>> findFirst() throws SQLException
        Returns:
        Throws:
        SQLException
      • findFirst

        public <T> com.landawn.abacus.util.u.Optional<T> findFirst(Class<? extends T> targetType) throws SQLException
        Type Parameters:
        T -
        Parameters:
        targetType -
        Returns:
        Throws:
        SQLException
      • findFirst

        public <T> com.landawn.abacus.util.u.Optional<T> findFirst(Jdbc.RowMapper<? extends T> rowMapper) throws SQLException, NullPointerException
        Type Parameters:
        T -
        Parameters:
        rowMapper -
        Returns:
        Throws:
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • findFirst

        @Deprecated public <T> com.landawn.abacus.util.u.Optional<T> findFirst(Jdbc.RowFilter rowFilter, Jdbc.RowMapper<? extends T> rowMapper) throws SQLException, NullPointerException
        Deprecated.
        Use {@link stream(RowFilter, RowMapper).first()} instead.
        Type Parameters:
        T -
        Parameters:
        rowFilter -
        rowMapper -
        Returns:
        Throws:
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • findFirst

        public <T> com.landawn.abacus.util.u.Optional<T> findFirst(Jdbc.BiRowMapper<? extends T> rowMapper) throws SQLException, NullPointerException
        Type Parameters:
        T -
        Parameters:
        rowMapper -
        Returns:
        Throws:
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • findFirst

        @Deprecated public <T> com.landawn.abacus.util.u.Optional<T> findFirst(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<? extends T> rowMapper) throws SQLException, NullPointerException
        Deprecated.
        Use {@link stream(BiRowFilter, BiRowMapper).first()} instead.
        Type Parameters:
        T -
        Parameters:
        rowFilter -
        rowMapper -
        Returns:
        Throws:
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • findFirstOrNull

        public Map<String,Object> findFirstOrNull() throws SQLException
        Returns:
        Throws:
        SQLException
      • findFirstOrNull

        public <T> T findFirstOrNull(Class<? extends T> targetType) throws SQLException
        Type Parameters:
        T -
        Parameters:
        targetType -
        Returns:
        Throws:
        SQLException
      • findFirstOrNull

        public <T> T findFirstOrNull(Jdbc.RowMapper<? extends T> rowMapper) throws SQLException, NullPointerException
        Type Parameters:
        T -
        Parameters:
        rowMapper -
        Returns:
        Throws:
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • findFirstOrNull

        @Deprecated public <T> T findFirstOrNull(Jdbc.RowFilter rowFilter, Jdbc.RowMapper<? extends T> rowMapper) throws SQLException, NullPointerException
        Deprecated.
        Use {@link stream(RowFilter, RowMapper).first()} instead.
        Type Parameters:
        T -
        Parameters:
        rowFilter -
        rowMapper -
        Returns:
        Throws:
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • findFirstOrNull

        public <T> T findFirstOrNull(Jdbc.BiRowMapper<? extends T> rowMapper) throws SQLException, NullPointerException
        Type Parameters:
        T -
        Parameters:
        rowMapper -
        Returns:
        Throws:
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • findFirstOrNull

        @Deprecated public <T> T findFirstOrNull(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<? extends T> rowMapper) throws SQLException, NullPointerException
        Deprecated.
        Use {@link stream(BiRowFilter, BiRowMapper).first()} instead.
        Type Parameters:
        T -
        Parameters:
        rowFilter -
        rowMapper -
        Returns:
        Throws:
        SQLException
        NullPointerException - if rowMapper returns null for the found record.
      • list

        public List<Map<String,Object>> list() throws SQLException
        Returns:
        Throws:
        SQLException
      • list

        public <T> List<T> list(Class<? extends T> targetType) throws SQLException
        Type Parameters:
        T -
        Parameters:
        targetType -
        Returns:
        Throws:
        SQLException
      • list

        @Deprecated public <T> List<T> list(Class<? extends T> targetType, int maxResult) throws SQLException
        Deprecated.
        the result size should be limited in database server side by sql scripts.
        Type Parameters:
        T -
        Parameters:
        targetType -
        maxResult -
        Returns:
        Throws:
        SQLException
      • list

        public <T> List<T> list(Jdbc.RowMapper<? extends T> rowMapper) throws SQLException
        Type Parameters:
        T -
        Parameters:
        rowMapper -
        Returns:
        Throws:
        SQLException
      • list

        @Deprecated public <T> List<T> list(Jdbc.RowMapper<? extends 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.RowFilter rowFilter, Jdbc.RowMapper<? extends T> rowMapper) throws SQLException
        Type Parameters:
        T -
        Parameters:
        rowFilter -
        rowMapper -
        Returns:
        Throws:
        SQLException
      • list

        public <T> List<T> list(Jdbc.RowFilter rowFilter, Jdbc.RowMapper<? extends T> rowMapper, int maxResult) throws SQLException
        Type Parameters:
        T -
        Parameters:
        rowFilter -
        rowMapper -
        maxResult -
        Returns:
        Throws:
        SQLException
      • list

        public <T> List<T> list(Jdbc.BiRowMapper<? extends T> rowMapper) throws SQLException
        Type Parameters:
        T -
        Parameters:
        rowMapper -
        Returns:
        Throws:
        SQLException
      • list

        @Deprecated public <T> List<T> list(Jdbc.BiRowMapper<? extends 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<? extends T> rowMapper) throws SQLException
        Type Parameters:
        T -
        Parameters:
        rowFilter -
        rowMapper -
        Returns:
        Throws:
        SQLException
      • list

        public <T> List<T> list(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<? extends T> rowMapper, int maxResult) throws SQLException
        Type Parameters:
        T -
        Parameters:
        rowFilter -
        rowMapper -
        maxResult -
        Returns:
        Throws:
        SQLException
      • stream

        public com.landawn.abacus.util.ExceptionalStream<Map<String,Object>,SQLException> stream()
        lazy-execution, lazy-fetch.
        Note: The opened Connection and Statement will be held on till @TerminalOp or @TerminalOpTriggered stream operation is called.
        Returns:
        See Also:
      • stream

        public <T> com.landawn.abacus.util.ExceptionalStream<T,SQLException> stream(Class<? extends T> targetType)
        lazy-execution, lazy-fetch.
        Note: The opened Connection and Statement will be held on till @TerminalOp or @TerminalOpTriggered stream operation is called.
        Type Parameters:
        T -
        Parameters:
        targetType -
        Returns:
        See Also:
      • stream

        public <T> com.landawn.abacus.util.ExceptionalStream<T,SQLException> stream(Jdbc.RowMapper<? extends T> rowMapper)
        lazy-execution, lazy-fetch.
        Note: The opened Connection and Statement 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<? extends T> rowMapper)
        lazy-execution, lazy-fetch.
        Note: The opened Connection and Statement 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<? extends T> rowMapper)
        lazy-execution, lazy-fetch.
        Note: The opened Connection and Statement 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<? extends T> rowMapper)
        lazy-execution, lazy-fetch.
        Note: The opened Connection and Statement will be held on till @TerminalOp or @TerminalOpTriggered stream operation is called.
        Type Parameters:
        T -
        Parameters:
        rowFilter -
        rowMapper -
        Returns:
        See Also:
      • exists

        public boolean exists() throws SQLException
        Note: using select 1 from ..., not select count(*) from ....
        Returns:
        true, if there is at least one record found.
        Throws:
        SQLException
      • notExists

        @Beta public boolean notExists() throws SQLException
        Why adding notExists()? not just exists() == false or !exists()? Because notExists() is not minor case. It's a general case. not exists is better expression than exists() == false or !exists().
        Note: using select 1 from ..., not select count(*) from ....
        Returns:
        true, if there is no record found.
        Throws:
        SQLException
        See Also:
      • ifExists

        public void ifExists(Jdbc.RowConsumer rowConsumer) throws SQLException
        Parameters:
        rowConsumer -
        Throws:
        SQLException
      • ifExists

        public void ifExists(Jdbc.BiRowConsumer rowConsumer) throws SQLException
        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 public int count() throws SQLException
        Deprecated.
        may be misused and it's inefficient.
        Uses queryForInt() with query select count(*) from ...
        Returns:
        Throws:
        SQLException
        See Also:
      • count

        public int count(Jdbc.RowFilter rowFilter) throws SQLException
        Parameters:
        rowFilter -
        Returns:
        Throws:
        SQLException
      • count

        public int count(Jdbc.BiRowFilter rowFilter) throws SQLException
        Parameters:
        rowFilter -
        Returns:
        Throws:
        SQLException
      • anyMatch

        public boolean anyMatch(Jdbc.RowFilter rowFilter) throws SQLException
        Parameters:
        rowFilter -
        Returns:
        true, if successful
        Throws:
        SQLException
      • anyMatch

        public boolean anyMatch(Jdbc.BiRowFilter rowFilter) throws SQLException
        Parameters:
        rowFilter -
        Returns:
        true, if successful
        Throws:
        SQLException
      • allMatch

        public boolean allMatch(Jdbc.RowFilter rowFilter) throws SQLException
        Parameters:
        rowFilter -
        Returns:
        true, if successful
        Throws:
        SQLException
      • allMatch

        public boolean allMatch(Jdbc.BiRowFilter rowFilter) throws SQLException
        Parameters:
        rowFilter -
        Returns:
        true, if successful
        Throws:
        SQLException
      • noneMatch

        public boolean noneMatch(Jdbc.RowFilter rowFilter) throws SQLException
        Parameters:
        rowFilter -
        Returns:
        true, if successful
        Throws:
        SQLException
      • noneMatch

        public boolean noneMatch(Jdbc.BiRowFilter rowFilter) throws SQLException
        Parameters:
        rowFilter -
        Returns:
        true, if successful
        Throws:
        SQLException
      • forEach

        public void forEach(Jdbc.RowConsumer rowConsumer) throws SQLException
        Parameters:
        rowConsumer -
        Throws:
        SQLException
      • forEach

        public void forEach(Jdbc.RowFilter rowFilter, Jdbc.RowConsumer rowConsumer) throws SQLException
        Parameters:
        rowFilter -
        rowConsumer -
        Throws:
        SQLException
      • forEach

        public void forEach(Jdbc.BiRowConsumer rowConsumer) throws SQLException
        Parameters:
        rowConsumer -
        Throws:
        SQLException
      • forEach

        public void forEach(Jdbc.BiRowFilter rowFilter, Jdbc.BiRowConsumer rowConsumer) throws SQLException
        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 from ResultSet by the type of fields/columns defined in this class.
        rowConsumer -
        Throws:
        SQLException
      • insert

        public <ID> com.landawn.abacus.util.u.Optional<ID> insert() throws SQLException
        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<? extends 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<? extends ID> autoGeneratedKeyExtractor) throws SQLException
        Type Parameters:
        ID -
        Parameters:
        autoGeneratedKeyExtractor -
        Returns:
        Throws:
        SQLException
      • batchInsert

        public <ID> List<ID> batchInsert() throws SQLException
        Returns the generated key if it exists.
        Type Parameters:
        ID -
        Returns:
        Throws:
        SQLException
      • batchInsert

        public <ID> List<ID> batchInsert(Jdbc.RowMapper<? extends ID> autoGeneratedKeyExtractor) throws SQLException
        Type Parameters:
        ID -
        Parameters:
        autoGeneratedKeyExtractor -
        Returns:
        Throws:
        SQLException
      • batchInsert

        public <ID> List<ID> batchInsert(Jdbc.BiRowMapper<? extends ID> autoGeneratedKeyExtractor) throws SQLException
        Type Parameters:
        ID -
        Parameters:
        autoGeneratedKeyExtractor -
        Returns:
        Throws:
        SQLException
      • update

        public int update() throws SQLException
        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

        public int[] batchUpdate() throws SQLException
        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

        public long largeUpdate() throws SQLException
        Returns:
        Throws:
        SQLException
      • largeBatchUpdate

        public long[] largeBatchUpdate() throws SQLException
        Large batch update.
        Returns:
        Throws:
        SQLException
      • execute

        public boolean execute() throws SQLException
        Returns:
        true, if successful
        Throws:
        SQLException
      • executeThenApply

        public <R> R executeThenApply(com.landawn.abacus.util.Throwables.Function<? super Stmt,? extends R,SQLException> getter) throws SQLException
        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,? extends R,SQLException> getter) throws SQLException
        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 SQLException
        Execute then accept.
        Parameters:
        consumer -
        Throws:
        SQLException
      • executeThenAccept

        public void executeThenAccept(com.landawn.abacus.util.Throwables.BiConsumer<Boolean,? super Stmt,SQLException> consumer) throws SQLException
        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 opened Connection and Statement will be held on till sqlAction 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 opened Connection and Statement will be held on till sqlAction 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 opened Connection and Statement will be held on till sqlAction 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 opened Connection and Statement will be held on till sqlAction is completed by another thread.
        Parameters:
        sqlAction -
        executor -
        Returns:
      • close

        public void close()
        Close.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable