Class JdbcUtil

java.lang.Object
com.landawn.abacus.jdbc.JdbcUtil

public final class JdbcUtil extends Object
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.

  • Since:
    0.8
    Author:
    Haiyang Li
    See Also:
    • Field Details

      • DEFAULT_BATCH_SIZE

        public static final int DEFAULT_BATCH_SIZE
        See Also:
      • DEFAULT_FETCH_SIZE_FOR_BIG_RESULT

        public static final int DEFAULT_FETCH_SIZE_FOR_BIG_RESULT
        See Also:
      • DEFAULT_FETCH_SIZE_FOR_STREAM

        public static final int DEFAULT_FETCH_SIZE_FOR_STREAM
        See Also:
      • DEFAULT_SQL_EXTRACTOR

        public static final com.landawn.abacus.util.Throwables.Function<Statement,String,SQLException> DEFAULT_SQL_EXTRACTOR
      • DEFAULT_MAX_SQL_LOG_LENGTH

        public static final int DEFAULT_MAX_SQL_LOG_LENGTH
        See Also:
      • DEFAULT_MIN_EXECUTION_TIME_FOR_DAO_METHOD_PERF_LOG

        public static final long DEFAULT_MIN_EXECUTION_TIME_FOR_DAO_METHOD_PERF_LOG
        See Also:
      • DEFAULT_MIN_EXECUTION_TIME_FOR_SQL_PERF_LOG

        public static final long DEFAULT_MIN_EXECUTION_TIME_FOR_SQL_PERF_LOG
        See Also:
    • Method Details

      • getDBProductInfo

        public static DBProductInfo getDBProductInfo(DataSource ds) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        ds -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException
      • getDBProductInfo

        public static DBProductInfo getDBProductInfo(Connection conn) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        conn -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException
      • createHikariDataSource

        public static DataSource createHikariDataSource(String url, String user, String password)
        Creates the DataSource.
        Parameters:
        url -
        user -
        password -
        Returns:
      • createC3p0DataSource

        public static DataSource createC3p0DataSource(String url, String user, String password)
        Creates the DataSource.
        Parameters:
        url -
        user -
        password -
        Returns:
      • createConnection

        public static Connection createConnection(String url, String user, String password) throws com.landawn.abacus.exception.UncheckedSQLException
        Creates the connection.
        Parameters:
        url -
        user -
        password -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • createConnection

        public static Connection createConnection(String driverClass, String url, String user, String password) throws com.landawn.abacus.exception.UncheckedSQLException
        Creates the connection.
        Parameters:
        driverClass -
        url -
        user -
        password -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • createConnection

        public static Connection createConnection(Class<? extends Driver> driverClass, String url, String user, String password) throws com.landawn.abacus.exception.UncheckedSQLException
        Creates the connection.
        Parameters:
        driverClass -
        url -
        user -
        password -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • getConnection

        public static Connection getConnection(DataSource ds) throws com.landawn.abacus.exception.UncheckedSQLException
        Spring Transaction is supported and Integrated. If this method is called where a Spring transaction is started with the specified DataSource, the Connection started the Spring Transaction will be returned. Otherwise a Connection directly from the specified DataSource(Connection pool) will be returned.
        Parameters:
        ds -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • releaseConnection

        public static void releaseConnection(Connection conn, DataSource ds)
        Spring Transaction is supported and Integrated. If this method is called where a Spring transaction is started with the specified DataSource, the specified Connection won't be returned to DataSource(Connection pool) until the transaction is committed or rolled back. Otherwise the specified Connection will be directly returned back to DataSource(Connection pool).
        Parameters:
        conn -
        ds -
      • close

        public static void close(ResultSet rs) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        rs -
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • close

        public static void close(ResultSet rs, boolean closeStatement) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        rs -
        closeStatement -
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • close

        public static void close(ResultSet rs, boolean closeStatement, boolean closeConnection) throws IllegalArgumentException, com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        rs -
        closeStatement -
        closeConnection -
        Throws:
        IllegalArgumentException - if closeStatement = false while closeConnection = true.
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • close

        public static void close(Statement stmt) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        stmt -
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • close

        @Deprecated public static void close(Connection conn) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        conn -
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • close

        public static void close(ResultSet rs, Statement stmt) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        rs -
        stmt -
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • close

        public static void close(Statement stmt, Connection conn) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        stmt -
        conn -
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • close

        public static void close(ResultSet rs, Statement stmt, Connection conn) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        rs -
        stmt -
        conn -
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • closeQuietly

        public static void closeQuietly(ResultSet rs)
        Unconditionally close an ResultSet.

        Equivalent to ResultSet.close(), except any exceptions will be ignored. This is typically used in finally blocks.

        Parameters:
        rs -
      • closeQuietly

        public static void closeQuietly(ResultSet rs, boolean closeStatement) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        rs -
        closeStatement -
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • closeQuietly

        public static void closeQuietly(ResultSet rs, boolean closeStatement, boolean closeConnection) throws IllegalArgumentException
        Parameters:
        rs -
        closeStatement -
        closeConnection -
        Throws:
        IllegalArgumentException - if closeStatement = false while closeConnection = true.
      • closeQuietly

        public static void closeQuietly(Statement stmt)
        Unconditionally close an Statement.

        Equivalent to Statement.close(), except any exceptions will be ignored. This is typically used in finally blocks.

        Parameters:
        stmt -
      • closeQuietly

        @Deprecated public static void closeQuietly(Connection conn)
        Unconditionally close an Connection.

        Equivalent to Connection.close(), except any exceptions will be ignored. This is typically used in finally blocks.

        Parameters:
        conn -
      • closeQuietly

        public static void closeQuietly(ResultSet rs, Statement stmt)
        Unconditionally close the ResultSet, Statement.

        Equivalent to ResultSet.close(), Statement.close(), except any exceptions will be ignored. This is typically used in finally blocks.

        Parameters:
        rs -
        stmt -
      • closeQuietly

        public static void closeQuietly(Statement stmt, Connection conn)
        Unconditionally close the Statement, Connection.

        Equivalent to Statement.close(), Connection.close(), except any exceptions will be ignored. This is typically used in finally blocks.

        Parameters:
        stmt -
        conn -
      • closeQuietly

        public static void closeQuietly(ResultSet rs, Statement stmt, Connection conn)
        Unconditionally close the ResultSet, Statement, Connection.

        Equivalent to ResultSet.close(), Statement.close(), Connection.close(), except any exceptions will be ignored. This is typically used in finally blocks.

        Parameters:
        rs -
        stmt -
        conn -
      • skip

        public static int skip(ResultSet rs, int n) throws SQLException
        Parameters:
        rs -
        n - the count of row to move ahead.
        Returns:
        Throws:
        SQLException
      • skip

        public static int skip(ResultSet rs, long n) throws SQLException
        Parameters:
        rs -
        n - the count of row to move ahead.
        Returns:
        Throws:
        SQLException
      • getColumnCount

        public static int getColumnCount(ResultSet rs) throws SQLException
        Gets the column count.
        Parameters:
        rs -
        Returns:
        Throws:
        SQLException
      • getColumnNameList

        public static List<String> getColumnNameList(Connection conn, String tableName) throws SQLException
        Gets the column name list.
        Parameters:
        conn -
        tableName -
        Returns:
        Throws:
        SQLException
      • getColumnLabelList

        public static List<String> getColumnLabelList(ResultSet rs) throws SQLException
        Parameters:
        rs -
        Returns:
        Throws:
        SQLException
      • getColumnLabel

        public static String getColumnLabel(ResultSetMetaData rsmd, int columnIndex) throws SQLException
        Gets the column label.
        Parameters:
        rsmd -
        columnIndex -
        Returns:
        Throws:
        SQLException
      • getColumnIndex

        public static int getColumnIndex(ResultSet resultSet, String columnName) throws com.landawn.abacus.exception.UncheckedSQLException
        Returns the column index starts with from 1, not 0.
        Parameters:
        resultSet -
        columnName -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • getColumnIndex

        public static int getColumnIndex(ResultSetMetaData rsmd, String columnName) throws SQLException
        Returns the column index starts with from 1, not 0.
        Parameters:
        rsmd -
        columnName -
        Returns:
        Throws:
        SQLException
      • getColumnValue

        public static Object getColumnValue(ResultSet rs, int columnIndex) throws SQLException
        Gets the column value.
        Parameters:
        rs -
        columnIndex - starts with 1, not 0.
        Returns:
        Throws:
        SQLException
      • getColumnValue

        @Deprecated public static Object getColumnValue(ResultSet rs, String columnLabel) throws SQLException
        Deprecated.
        please consider using getColumnValue(ResultSet, int)
        Gets the column value.
        Parameters:
        rs -
        columnLabel -
        Returns:
        Throws:
        SQLException
      • getAllColumnValues

        public static <T> List<T> getAllColumnValues(ResultSet rs, int columnIndex) throws SQLException
        Gets the column value.
        Type Parameters:
        T -
        Parameters:
        rs -
        columnIndex - starts with 1, not 0.
        Returns:
        Throws:
        SQLException
      • getAllColumnValues

        public static <T> List<T> getAllColumnValues(ResultSet rs, String columnLabel) throws SQLException
        Gets the column value.
        Type Parameters:
        T -
        Parameters:
        rs -
        columnLabel -
        Returns:
        Throws:
        SQLException
      • getColumnValue

        public static <T> T getColumnValue(ResultSet rs, int columnIndex, Class<? extends T> targetClass) throws SQLException
        Gets the column value.
        Type Parameters:
        T -
        Parameters:
        rs -
        columnIndex -
        targetClass -
        Returns:
        Throws:
        SQLException
      • getColumnValue

        @Deprecated public static <T> T getColumnValue(ResultSet rs, String columnLabel, Class<? extends T> targetClass) throws SQLException
        Deprecated.
        Gets the column value.
        Type Parameters:
        T -
        Parameters:
        rs -
        columnLabel -
        targetClass -
        Returns:
        Throws:
        SQLException
      • getColumn2FieldNameMap

        public static com.landawn.abacus.util.ImmutableMap<String,String> getColumn2FieldNameMap(Class<?> entityClass)
        Parameters:
        entityClass -
        Returns:
      • isInTransaction

        public static boolean isInTransaction(DataSource ds)
        Parameters:
        ds -
        Returns:
      • beginTransaction

        public static SQLTransaction beginTransaction(DataSource dataSource) throws com.landawn.abacus.exception.UncheckedSQLException
        Refer to: beginTransaction(javax.sql.DataSource, IsolationLevel, boolean).
        Parameters:
        dataSource -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • beginTransaction

        public static SQLTransaction beginTransaction(DataSource dataSource, IsolationLevel isolationLevel) throws com.landawn.abacus.exception.UncheckedSQLException
        Refer to: beginTransaction(javax.sql.DataSource, IsolationLevel, boolean).
        Parameters:
        dataSource -
        isolationLevel -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
      • beginTransaction

        public static SQLTransaction beginTransaction(DataSource dataSource, IsolationLevel isolationLevel, boolean isForUpdateOnly) throws com.landawn.abacus.exception.UncheckedSQLException
        Starts a global transaction which will be shared by all in-line database query with the same DataSource in the same thread, including methods: JdbcUtil.beginTransaction/prepareQuery/prepareNamedQuery/prepareCallableQuery, SQLExecutor(Mapper).beginTransaction/get/insert/batchInsert/update/batchUpdate/query/list/findFirst/...
        Spring Transaction is supported and Integrated. If this method is called at where a Spring transaction is started with the specified DataSource, the Connection started the Spring Transaction will be used here. That's to say the Spring transaction will have the final control on commit/roll back over the Connection.

        Here is the general code pattern to work with SQLTransaction.
         
         public void doSomethingA() {
             ...
             final SQLTransaction tranA = JdbcUtil.beginTransaction(dataSource1, isolation);
        
             try {
                 ...
                 doSomethingB(); // Share the same transaction 'tranA' because they're in the same thread and start transaction with same DataSource 'dataSource1'.
                 ...
                 doSomethingC(); // won't share the same transaction 'tranA' although they're in the same thread but start transaction with different DataSource 'dataSource2'.
                 ...
                 tranA.commit();
             } finally {
                 tranA.rollbackIfNotCommitted();
             }
         }
        
         public void doSomethingB() {
             ...
             final SQLTransaction tranB = JdbcUtil.beginTransaction(dataSource1, isolation);
             try {
                 // do your work with the conn...
                 ...
                 tranB.commit();
             } finally {
                 tranB.rollbackIfNotCommitted();
             }
         }
        
         public void doSomethingC() {
             ...
             final SQLTransaction tranC = JdbcUtil.beginTransaction(dataSource2, isolation);
             try {
                 // do your work with the conn...
                 ...
                 tranC.commit();
             } finally {
                 tranC.rollbackIfNotCommitted();
             }
         }
         
        It's incorrect to use flag to identity the transaction should be committed or rolled back. Don't write below code:
         
         public void doSomethingA() {
             ...
             final SQLTransaction tranA = JdbcUtil.beginTransaction(dataSource1, isolation);
             boolean flagToCommit = false;
             try {
                 // do your work with the conn...
                 ...
                 flagToCommit = true;
             } finally {
                 if (flagToCommit) {
                     tranA.commit();
                 } else {
                     tranA.rollbackIfNotCommitted();
                 }
             }
         }
         
         
        Parameters:
        dataSource -
        isolationLevel -
        isForUpdateOnly -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException - the unchecked SQL exception
        See Also:
        • SQLExecutor#beginTransaction(IsolationLevel, boolean, JdbcSettings)
      • callInTransaction

        @Beta public static <T, E extends Throwable> T callInTransaction(DataSource dataSource, com.landawn.abacus.util.Throwables.Callable<T,E> cmd) throws E
        Type Parameters:
        T -
        E -
        Parameters:
        dataSource -
        cmd -
        Returns:
        Throws:
        E
      • callInTransaction

        @Beta public static <T, E extends Throwable> T callInTransaction(DataSource dataSource, com.landawn.abacus.util.Throwables.Function<Connection,T,E> cmd) throws E
        Type Parameters:
        T -
        E -
        Parameters:
        dataSource -
        cmd -
        Returns:
        Throws:
        E
      • runInTransaction

        @Beta public static <E extends Throwable> void runInTransaction(DataSource dataSource, com.landawn.abacus.util.Throwables.Runnable<E> cmd) throws E
        Type Parameters:
        E -
        Parameters:
        dataSource -
        cmd -
        Throws:
        E
      • runInTransaction

        @Beta public static <E extends Throwable> void runInTransaction(DataSource dataSource, com.landawn.abacus.util.Throwables.Consumer<Connection,E> cmd) throws E
        Type Parameters:
        E -
        Parameters:
        dataSource -
        cmd -
        Throws:
        E
      • callNotInStartedTransaction

        @Beta public static <T, E extends Throwable> T callNotInStartedTransaction(DataSource dataSource, com.landawn.abacus.util.Throwables.Callable<T,E> cmd) throws E
        Type Parameters:
        T -
        E -
        Parameters:
        dataSource -
        cmd -
        Returns:
        Throws:
        E
      • callNotInStartedTransaction

        @Beta public static <T, E extends Throwable> T callNotInStartedTransaction(DataSource dataSource, com.landawn.abacus.util.Throwables.Function<DataSource,T,E> cmd) throws E
        Type Parameters:
        T -
        E -
        Parameters:
        dataSource -
        cmd -
        Returns:
        Throws:
        E
      • runNotInStartedTransaction

        @Beta public static <E extends Throwable> void runNotInStartedTransaction(DataSource dataSource, com.landawn.abacus.util.Throwables.Runnable<E> cmd) throws E
        Type Parameters:
        E -
        Parameters:
        dataSource -
        cmd -
        Throws:
        E
      • runNotInStartedTransaction

        @Beta public static <E extends Throwable> void runNotInStartedTransaction(DataSource dataSource, com.landawn.abacus.util.Throwables.Consumer<DataSource,E> cmd) throws E
        Type Parameters:
        E -
        Parameters:
        dataSource -
        cmd -
        Throws:
        E
      • prepareQuery

        public static PreparedQuery prepareQuery(DataSource ds, String sql) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        sql -
        Returns:
        Throws:
        SQLException
        See Also:
      • prepareQuery

        public static PreparedQuery prepareQuery(DataSource ds, String sql, boolean autoGeneratedKeys) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        sql -
        autoGeneratedKeys -
        Returns:
        Throws:
        SQLException
        See Also:
      • prepareQuery

        public static PreparedQuery prepareQuery(DataSource ds, String sql, int[] returnColumnIndexes) throws SQLException
        Parameters:
        ds -
        sql -
        returnColumnIndexes -
        Returns:
        Throws:
        SQLException
      • prepareQuery

        public static PreparedQuery prepareQuery(DataSource ds, String sql, String[] returnColumnNames) throws SQLException
        Parameters:
        ds -
        sql -
        returnColumnNames -
        Returns:
        Throws:
        SQLException
      • prepareQuery

        public static PreparedQuery prepareQuery(DataSource ds, String sql, com.landawn.abacus.util.Throwables.BiFunction<Connection,String,PreparedStatement,SQLException> stmtCreator) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        sql -
        stmtCreator - the created PreparedStatement will be closed after any execution methods in PreparedQuery/CallableQuery is called. An execution method is a method which will trigger the backed PreparedStatement/CallableStatement to be executed, for example: get/query/queryForInt/Long/../findFirst/findOnlyOne/list/execute/....
        Returns:
        Throws:
        SQLException
        See Also:
      • prepareQuery

        public static PreparedQuery prepareQuery(Connection conn, String sql) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareQuery(dataSource.getConnection(), sql);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        sql -
        Returns:
        Throws:
        SQLException
      • prepareQuery

        public static PreparedQuery prepareQuery(Connection conn, String sql, boolean autoGeneratedKeys) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareQuery(dataSource.getConnection(), sql, autoGeneratedKeys);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        sql -
        autoGeneratedKeys -
        Returns:
        Throws:
        SQLException
      • prepareQuery

        public static PreparedQuery prepareQuery(Connection conn, String sql, int[] returnColumnIndexes) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareQuery(dataSource.getConnection(), sql, returnColumnIndexes);
         
         
        Parameters:
        conn -
        sql -
        returnColumnIndexes -
        Returns:
        Throws:
        SQLException
      • prepareQuery

        public static PreparedQuery prepareQuery(Connection conn, String sql, String[] returnColumnNames) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareQuery(dataSource.getConnection(), sql, returnColumnNames);
         
         
        Parameters:
        conn -
        sql -
        returnColumnNames -
        Returns:
        Throws:
        SQLException
      • prepareQuery

        public static PreparedQuery prepareQuery(Connection conn, String sql, com.landawn.abacus.util.Throwables.BiFunction<Connection,String,PreparedStatement,SQLException> stmtCreator) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareQuery(dataSource.getConnection(), sql, stmtCreator);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        sql -
        stmtCreator - the created PreparedStatement will be closed after any execution methods in PreparedQuery/CallableQuery is called. An execution method is a method which will trigger the backed PreparedStatement/CallableStatement to be executed, for example: get/query/queryForInt/Long/../findFirst/findOnlyOne/list/execute/....
        Returns:
        Throws:
        SQLException
      • prepareQueryForBigResult

        @Beta public static PreparedQuery prepareQueryForBigResult(DataSource ds, String sql) throws SQLException
        Prepare select query for big result set. Fetch direction will be set to FetchDirection.FORWARD and fetch size will be set to DEFAULT_FETCH_SIZE_FOR_BIG_RESULT=1000.
        Parameters:
        ds -
        sql -
        Returns:
        Throws:
        SQLException
      • prepareQueryForBigResult

        @Beta public static PreparedQuery prepareQueryForBigResult(Connection conn, String sql) throws SQLException
        Prepare select query for big result set. Fetch direction will be set to FetchDirection.FORWARD and fetch size will be set to DEFAULT_FETCH_SIZE_FOR_BIG_RESULT=1000.
        Parameters:
        conn -
        sql -
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(DataSource ds, String namedSql) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        Returns:
        Throws:
        SQLException
        See Also:
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(DataSource ds, String namedSql, boolean autoGeneratedKeys) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        autoGeneratedKeys -
        Returns:
        Throws:
        SQLException
        See Also:
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(DataSource ds, String namedSql, int[] returnColumnIndexes) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        returnColumnIndexes -
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(DataSource ds, String namedSql, String[] returnColumnNames) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        returnColumnNames -
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(DataSource ds, String namedSql, com.landawn.abacus.util.Throwables.BiFunction<Connection,String,PreparedStatement,SQLException> stmtCreator) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        stmtCreator - the created PreparedStatement will be closed after any execution methods in NamedQuery/CallableQuery is called. An execution method is a method which will trigger the backed PreparedStatement/CallableStatement to be executed, for example: get/query/queryForInt/Long/../findFirst/findOnlyOne/list/execute/....
        Returns:
        Throws:
        SQLException
        See Also:
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(Connection conn, String namedSql) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareNamedQuery(dataSource.getConnection(), namedSql);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(Connection conn, String namedSql, boolean autoGeneratedKeys) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareNamedQuery(dataSource.getConnection(), namedSql, autoGeneratedKeys);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        autoGeneratedKeys -
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(Connection conn, String namedSql, int[] returnColumnIndexes) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareNamedQuery(dataSource.getConnection(), namedSql);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        returnColumnIndexes -
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(Connection conn, String namedSql, String[] returnColumnNames) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareNamedQuery(dataSource.getConnection(), namedSql);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        returnColumnNames -
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(Connection conn, String namedSql, com.landawn.abacus.util.Throwables.BiFunction<Connection,String,PreparedStatement,SQLException> stmtCreator) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareNamedQuery(dataSource.getConnection(), namedSql, stmtCreator);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        stmtCreator - the created PreparedStatement will be closed after any execution methods in NamedQuery/CallableQuery is called. An execution method is a method which will trigger the backed PreparedStatement/CallableStatement to be executed, for example: get/query/queryForInt/Long/../findFirst/findOnlyOne/list/execute/....
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(DataSource ds, com.landawn.abacus.util.ParsedSql namedSql) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        Returns:
        Throws:
        SQLException
        See Also:
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(DataSource ds, com.landawn.abacus.util.ParsedSql namedSql, boolean autoGeneratedKeys) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        autoGeneratedKeys -
        Returns:
        Throws:
        SQLException
        See Also:
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(DataSource ds, com.landawn.abacus.util.ParsedSql namedSql, int[] returnColumnIndexes) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        returnColumnIndexes -
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(DataSource ds, com.landawn.abacus.util.ParsedSql namedSql, String[] returnColumnNames) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        returnColumnNames -
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(DataSource ds, com.landawn.abacus.util.ParsedSql namedSql, com.landawn.abacus.util.Throwables.BiFunction<Connection,String,PreparedStatement,SQLException> stmtCreator) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        stmtCreator - the created PreparedStatement will be closed after any execution methods in NamedQuery/CallableQuery is called. An execution method is a method which will trigger the backed PreparedStatement/CallableStatement to be executed, for example: get/query/queryForInt/Long/../findFirst/findOnlyOne/list/execute/....
        Returns:
        Throws:
        SQLException
        See Also:
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(Connection conn, com.landawn.abacus.util.ParsedSql namedSql) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareNamedQuery(dataSource.getConnection(), namedSql);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(Connection conn, com.landawn.abacus.util.ParsedSql namedSql, boolean autoGeneratedKeys) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareNamedQuery(dataSource.getConnection(), namedSql, autoGeneratedKeys);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        autoGeneratedKeys -
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(Connection conn, com.landawn.abacus.util.ParsedSql namedSql, int[] returnColumnIndexes) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareNamedQuery(dataSource.getConnection(), namedSql);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        returnColumnIndexes -
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(Connection conn, com.landawn.abacus.util.ParsedSql namedSql, String[] returnColumnNames) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareNamedQuery(dataSource.getConnection(), namedSql);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        returnColumnNames -
        Returns:
        Throws:
        SQLException
      • prepareNamedQuery

        public static NamedQuery prepareNamedQuery(Connection conn, com.landawn.abacus.util.ParsedSql namedSql, com.landawn.abacus.util.Throwables.BiFunction<Connection,String,PreparedStatement,SQLException> stmtCreator) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareNamedQuery(dataSource.getConnection(), namedSql, stmtCreator);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        namedSql - for example SELECT first_name, last_name FROM account where id = :id
        stmtCreator - the created PreparedStatement will be closed after any execution methods in NamedQuery/CallableQuery is called. An execution method is a method which will trigger the backed PreparedStatement/CallableStatement to be executed, for example: get/query/queryForInt/Long/../findFirst/findOnlyOne/list/execute/....
        Returns:
        Throws:
        SQLException
      • prepareNamedQueryForBigResult

        @Beta public static NamedQuery prepareNamedQueryForBigResult(DataSource ds, String sql) throws SQLException
        Prepare select query for big result set. Fetch direction will be set to FetchDirection.FORWARD and fetch size will be set to DEFAULT_FETCH_SIZE_FOR_BIG_RESULT=1000.
        Parameters:
        ds -
        sql -
        Returns:
        Throws:
        SQLException
      • prepareNamedQueryForBigResult

        @Beta public static NamedQuery prepareNamedQueryForBigResult(Connection conn, String sql) throws SQLException
        Prepare select query for big result set. Fetch direction will be set to FetchDirection.FORWARD and fetch size will be set to DEFAULT_FETCH_SIZE_FOR_BIG_RESULT=1000.
        Parameters:
        conn -
        sql -
        Returns:
        Throws:
        SQLException
      • prepareCallableQuery

        public static CallableQuery prepareCallableQuery(DataSource ds, String sql) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        sql -
        Returns:
        Throws:
        SQLException
        See Also:
      • prepareCallableQuery

        public static CallableQuery prepareCallableQuery(DataSource ds, String sql, com.landawn.abacus.util.Throwables.BiFunction<Connection,String,CallableStatement,SQLException> stmtCreator) throws SQLException
        If this method is called where a transaction is started by JdbcUtil.beginTransaction or in Spring with the same DataSource in the same thread, the Connection started the Transaction will be used here. Otherwise a Connection directly from the specified DataSource(Connection pool) will be borrowed and used.
        Parameters:
        ds -
        sql -
        stmtCreator - the created CallableStatement will be closed after any execution methods in PreparedQuery/CallableQuery is called. An execution method is a method which will trigger the backed PreparedStatement/CallableStatement to be executed, for example: get/query/queryForInt/Long/../findFirst/findOnlyOne/list/execute/....
        Returns:
        Throws:
        SQLException
        See Also:
      • prepareCallableQuery

        public static CallableQuery prepareCallableQuery(Connection conn, String sql) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareCallableQuery(dataSource.getConnection(), sql);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        sql -
        Returns:
        Throws:
        SQLException
        See Also:
      • prepareCallableQuery

        public static CallableQuery prepareCallableQuery(Connection conn, String sql, com.landawn.abacus.util.Throwables.BiFunction<Connection,String,CallableStatement,SQLException> stmtCreator) throws SQLException
        Never write below code because it will definitely cause Connection leak:
         
         JdbcUtil.prepareCallableQuery(dataSource.getConnection(), sql, stmtCreator);
         
         
        Parameters:
        conn - the specified conn won't be close after this query is executed.
        sql -
        stmtCreator - the created CallableStatement will be closed after any execution methods in PreparedQuery/CallableQuery is called. An execution method is a method which will trigger the backed PreparedStatement/CallableStatement to be executed, for example: get/query/queryForInt/Long/../findFirst/findOnlyOne/list/execute/....
        Returns:
        Throws:
        SQLException
      • executeQuery

        @SafeVarargs public static com.landawn.abacus.util.DataSet executeQuery(DataSource ds, String sql, Object... parameters) throws SQLException
        Parameters:
        ds -
        sql -
        parameters -
        Returns:
        Throws:
        SQLException
      • executeQuery

        @SafeVarargs public static com.landawn.abacus.util.DataSet executeQuery(Connection conn, String sql, Object... parameters) throws SQLException
        Parameters:
        conn -
        sql -
        parameters -
        Returns:
        Throws:
        SQLException
      • executeUpdate

        @SafeVarargs public static int executeUpdate(DataSource ds, String sql, Object... parameters) throws SQLException
        Parameters:
        ds -
        sql -
        parameters -
        Returns:
        Throws:
        SQLException
      • executeUpdate

        @SafeVarargs public static int executeUpdate(Connection conn, String sql, Object... parameters) throws SQLException
        Parameters:
        conn -
        sql -
        parameters -
        Returns:
        Throws:
        SQLException
      • executeBatchUpdate

        public static int executeBatchUpdate(DataSource ds, String sql, List<?> listOfParameters) throws SQLException
        Parameters:
        ds -
        sql -
        listOfParameters -
        Returns:
        Throws:
        SQLException
      • executeBatchUpdate

        public static int executeBatchUpdate(DataSource ds, String sql, List<?> listOfParameters, int batchSize) throws SQLException
        Parameters:
        ds -
        sql -
        listOfParameters -
        batchSize -
        Returns:
        Throws:
        SQLException
      • executeBatchUpdate

        public static int executeBatchUpdate(Connection conn, String sql, List<?> listOfParameters) throws SQLException
        Execute batch update.
        Parameters:
        conn -
        sql -
        listOfParameters -
        Returns:
        Throws:
        SQLException
      • executeBatchUpdate

        public static int executeBatchUpdate(Connection conn, String sql, List<?> listOfParameters, int batchSize) throws SQLException
        Execute batch update.
        Parameters:
        conn -
        sql -
        listOfParameters -
        batchSize -
        Returns:
        Throws:
        SQLException
      • executeLargeBatchUpdate

        public static long executeLargeBatchUpdate(DataSource ds, String sql, List<?> listOfParameters) throws SQLException
        Parameters:
        ds -
        sql -
        listOfParameters -
        Returns:
        Throws:
        SQLException
      • executeLargeBatchUpdate

        public static long executeLargeBatchUpdate(DataSource ds, String sql, List<?> listOfParameters, int batchSize) throws SQLException
        Parameters:
        ds -
        sql -
        listOfParameters -
        batchSize -
        Returns:
        Throws:
        SQLException
      • executeLargeBatchUpdate

        public static long executeLargeBatchUpdate(Connection conn, String sql, List<?> listOfParameters) throws SQLException
        Execute batch update.
        Parameters:
        conn -
        sql -
        listOfParameters -
        Returns:
        Throws:
        SQLException
      • executeLargeBatchUpdate

        public static long executeLargeBatchUpdate(Connection conn, String sql, List<?> listOfParameters, int batchSize) throws SQLException
        Execute batch update.
        Parameters:
        conn -
        sql -
        listOfParameters -
        batchSize -
        Returns:
        Throws:
        SQLException
      • execute

        @SafeVarargs public static boolean execute(DataSource ds, String sql, Object... parameters) throws SQLException
        Parameters:
        ds -
        sql -
        parameters -
        Returns:
        Throws:
        SQLException
      • execute

        @SafeVarargs public static boolean execute(Connection conn, String sql, Object... parameters) throws SQLException
        Parameters:
        conn -
        sql -
        parameters -
        Returns:
        true, if successful
        Throws:
        SQLException
      • extractData

        public static com.landawn.abacus.util.DataSet extractData(ResultSet rs) throws SQLException
        Parameters:
        rs -
        Returns:
        Throws:
        SQLException
      • extractData

        public static com.landawn.abacus.util.DataSet extractData(ResultSet rs, int offset, int count) throws SQLException
        Parameters:
        rs -
        offset -
        count -
        Returns:
        Throws:
        SQLException
      • extractData

        public static com.landawn.abacus.util.DataSet extractData(ResultSet rs, Jdbc.RowFilter filter) throws SQLException
        Parameters:
        rs -
        filter -
        Returns:
        Throws:
        SQLException
      • extractData

        public static com.landawn.abacus.util.DataSet extractData(ResultSet rs, Jdbc.RowExtractor rowExtractor) throws SQLException
        Parameters:
        rs -
        rowExtractor -
        Returns:
        Throws:
        SQLException
      • extractData

        public static com.landawn.abacus.util.DataSet extractData(ResultSet rs, Jdbc.RowFilter filter, Jdbc.RowExtractor rowExtractor) throws SQLException
        Parameters:
        rs -
        filter -
        rowExtractor -
        Returns:
        Throws:
        SQLException
      • extractData

        public static com.landawn.abacus.util.DataSet extractData(ResultSet rs, boolean closeResultSet) throws SQLException
        Parameters:
        rs -
        closeResultSet -
        Returns:
        Throws:
        SQLException
      • extractData

        public static com.landawn.abacus.util.DataSet extractData(ResultSet rs, int offset, int count, boolean closeResultSet) throws SQLException
        Parameters:
        rs -
        offset -
        count -
        closeResultSet -
        Returns:
        Throws:
        SQLException
      • extractData

        public static com.landawn.abacus.util.DataSet extractData(ResultSet rs, int offset, int count, Jdbc.RowFilter filter, boolean closeResultSet) throws SQLException
        Parameters:
        rs -
        offset -
        count -
        filter -
        closeResultSet -
        Returns:
        Throws:
        SQLException
      • extractData

        public static com.landawn.abacus.util.DataSet extractData(ResultSet rs, int offset, int count, Jdbc.RowExtractor rowExtractor, boolean closeResultSet) throws SQLException
        Parameters:
        rs -
        offset -
        count -
        rowExtractor -
        closeResultSet -
        Returns:
        Throws:
        SQLException
      • extractData

        public static com.landawn.abacus.util.DataSet extractData(ResultSet rs, int offset, int count, Jdbc.RowFilter filter, Jdbc.RowExtractor rowExtractor, boolean closeResultSet) throws SQLException
        Parameters:
        rs -
        offset -
        count -
        filter -
        rowExtractor -
        closeResultSet -
        Returns:
        Throws:
        SQLException
      • extractAllResultSets

        public static com.landawn.abacus.util.CheckedStream<com.landawn.abacus.util.DataSet,SQLException> extractAllResultSets(Statement stmt)
        It's user's responsibility to close the input stmt after the stream is finished, or call:
        JdbcUtil.extractAllResultSets(stmt).onClose(Fn.closeQuietly(stmt))...
        Parameters:
        stmt -
        Returns:
      • extractAllResultSets

        public static <T> com.landawn.abacus.util.CheckedStream<T,SQLException> extractAllResultSets(Statement stmt, Jdbc.ResultExtractor<T> resultExtractor)
        It's user's responsibility to close the input stmt after the stream is finished, or call:
        JdbcUtil.extractAllResultSets(stmt, resultExtractor).onClose(Fn.closeQuietly(stmt))...
        Type Parameters:
        T -
        Parameters:
        stmt -
        resultExtractor -
        Returns:
      • extractAllResultSets

        public static <T> com.landawn.abacus.util.CheckedStream<T,SQLException> extractAllResultSets(Statement stmt, Jdbc.BiResultExtractor<T> resultExtractor)
        It's user's responsibility to close the input stmt after the stream is finished, or call:
        JdbcUtil.extractAllResultSets(stmt, resultExtractor).onClose(Fn.closeQuietly(stmt))...
        Type Parameters:
        T -
        Parameters:
        stmt -
        resultExtractor -
        Returns:
      • stream

        public static com.landawn.abacus.util.CheckedStream<Object[],SQLException> stream(ResultSet resultSet)
        It's user's responsibility to close the input resultSet after the stream is finished, or call:
        JdbcUtil.stream(resultset).onClose(Fn.closeQuietly(resultSet))...
        Parameters:
        resultSet -
        Returns:
      • stream

        public static <T> com.landawn.abacus.util.CheckedStream<T,SQLException> stream(ResultSet resultSet, Class<? extends T> targetClass)
        It's user's responsibility to close the input resultSet after the stream is finished, or call:
        JdbcUtil.stream(resultset).onClose(Fn.closeQuietly(resultSet))...
        Type Parameters:
        T -
        Parameters:
        resultSet -
        targetClass - Array/List/Map or Entity with getter/setter methods.
        Returns:
      • stream

        public static <T> com.landawn.abacus.util.CheckedStream<T,SQLException> stream(ResultSet resultSet, Jdbc.RowMapper<? extends T> rowMapper)
        It's user's responsibility to close the input resultSet after the stream is finished, or call:
        JdbcUtil.stream(resultset).onClose(Fn.closeQuietly(resultSet))...
        Type Parameters:
        T -
        Parameters:
        resultSet -
        rowMapper -
        Returns:
      • stream

        public static <T> com.landawn.abacus.util.CheckedStream<T,SQLException> stream(ResultSet resultSet, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<? extends T> rowMapper)
        It's user's responsibility to close the input resultSet after the stream is finished, or call:
        JdbcUtil.stream(resultset).onClose(Fn.closeQuietly(resultSet))...
        Type Parameters:
        T -
        Parameters:
        resultSet -
        rowFilter -
        rowMapper -
        Returns:
      • stream

        public static <T> com.landawn.abacus.util.CheckedStream<T,SQLException> stream(ResultSet resultSet, Jdbc.BiRowMapper<? extends T> rowMapper)
        It's user's responsibility to close the input resultSet after the stream is finished, or call:
        JdbcUtil.stream(resultset).onClose(Fn.closeQuietly(resultSet))...
        Type Parameters:
        T -
        Parameters:
        resultSet -
        rowMapper -
        Returns:
      • stream

        public static <T> com.landawn.abacus.util.CheckedStream<T,SQLException> stream(ResultSet resultSet, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<? extends T> rowMapper)
        It's user's responsibility to close the input resultSet after the stream is finished, or call:
        JdbcUtil.stream(resultset).onClose(Fn.closeQuietly(resultSet))...
        Type Parameters:
        T -
        Parameters:
        resultSet -
        rowFilter -
        rowMapper -
        Returns:
      • stream

        public static <T> com.landawn.abacus.util.CheckedStream<T,SQLException> stream(ResultSet resultSet, int columnIndex)
        It's user's responsibility to close the input resultSet after the stream is finished, or call:
        JdbcUtil.stream(resultset).onClose(Fn.closeQuietly(resultSet))...
        Type Parameters:
        T -
        Parameters:
        resultSet -
        columnIndex - starts from 1, not 0.
        Returns:
      • stream

        public static <T> com.landawn.abacus.util.CheckedStream<T,SQLException> stream(ResultSet resultSet, String columnName)
        It's user's responsibility to close the input resultSet after the stream is finished, or call:
        JdbcUtil.stream(resultset).onClose(Fn.closeQuietly(resultSet))...
        Type Parameters:
        T -
        Parameters:
        resultSet -
        columnName -
        Returns:
      • streamAllResultSets

        public static <T> com.landawn.abacus.util.CheckedStream<com.landawn.abacus.util.CheckedStream<T,SQLException>,SQLException> streamAllResultSets(Statement stmt, Class<? extends T> targetClass)
        It's user's responsibility to close the input stmt after the stream is finished, or call:
        JdbcUtil.streamAllResultSets(stmt, targetClass).onClose(Fn.closeQuietly(stmt))...
        Type Parameters:
        T -
        Parameters:
        stmt -
        targetClass -
        Returns:
      • streamAllResultSets

        public static <T> com.landawn.abacus.util.CheckedStream<com.landawn.abacus.util.CheckedStream<T,SQLException>,SQLException> streamAllResultSets(Statement stmt, Jdbc.RowMapper<? extends T> rowMapper)
        It's user's responsibility to close the input stmt after the stream is finished, or call:
        JdbcUtil.streamAllResultSets(stmt, rowMapper).onClose(Fn.closeQuietly(stmt))...
        Type Parameters:
        T -
        Parameters:
        stmt -
        rowMapper -
        Returns:
      • streamAllResultSets

        public static <T> com.landawn.abacus.util.CheckedStream<com.landawn.abacus.util.CheckedStream<T,SQLException>,SQLException> streamAllResultSets(Statement stmt, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<? extends T> rowMapper)
        It's user's responsibility to close the input stmt after the stream is finished, or call:
        JdbcUtil.streamAllResultSets(stmt, rowFilter, rowMapper).onClose(Fn.closeQuietly(stmt))...
        Type Parameters:
        T -
        Parameters:
        stmt -
        rowFilter -
        rowMapper -
        Returns:
      • streamAllResultSets

        public static <T> com.landawn.abacus.util.CheckedStream<com.landawn.abacus.util.CheckedStream<T,SQLException>,SQLException> streamAllResultSets(Statement stmt, Jdbc.BiRowMapper<? extends T> rowMapper)
        It's user's responsibility to close the input stmt after the stream is finished, or call:
        JdbcUtil.streamAllResultSets(stmt, rowMapper).onClose(Fn.closeQuietly(stmt))...
        Type Parameters:
        T -
        Parameters:
        stmt -
        rowMapper -
        Returns:
      • streamAllResultSets

        public static <T> com.landawn.abacus.util.CheckedStream<com.landawn.abacus.util.CheckedStream<T,SQLException>,SQLException> streamAllResultSets(Statement stmt, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<? extends T> rowMapper)
        It's user's responsibility to close the input stmt after the stream is finished, or call:
        JdbcUtil.streamAllResultSets(stmt, rowFilter, rowMapper).onClose(Fn.closeQuietly(stmt))...
        Type Parameters:
        T -
        Parameters:
        stmt -
        rowFilter -
        rowMapper -
        Returns:
      • queryByPage

        public static com.landawn.abacus.util.CheckedStream<com.landawn.abacus.util.DataSet,SQLException> queryByPage(DataSource ds, String query, int pageSize, Jdbc.BiParametersSetter<? super AbstractQuery,com.landawn.abacus.util.DataSet> paramSetter)
        Runs a Stream with each element(page) is loaded from database table by running sql query.
        Parameters:
        ds -
        query - this query must be ordered by at least one key/id and has the result size limitation: for example LIMIT pageSize, ROWS FETCH NEXT pageSize ROWS ONLY
        pageSize -
        paramSetter - the second parameter is the result set for previous page. it's null for first page.
        Returns:
      • queryByPage

        public static <R> com.landawn.abacus.util.CheckedStream<R,SQLException> queryByPage(DataSource ds, String query, int pageSize, Jdbc.BiParametersSetter<? super AbstractQuery,R> paramSetter, Jdbc.ResultExtractor<R> resultExtractor)
        Runs a Stream with each element(page) is loaded from database table by running sql query.
        Type Parameters:
        R -
        Parameters:
        ds -
        query - this query must be ordered by at least one key/id and has the result size limitation: for example LIMIT pageSize, ROWS FETCH NEXT pageSize ROWS ONLY
        pageSize -
        paramSetter - the second parameter is the result set for previous page. it's null for first page.
        resultExtractor -
        Returns:
      • queryByPage

        public static <R> com.landawn.abacus.util.CheckedStream<R,SQLException> queryByPage(DataSource ds, String query, int pageSize, Jdbc.BiParametersSetter<? super AbstractQuery,R> paramSetter, Jdbc.BiResultExtractor<R> resultExtractor)
        Runs a Stream with each element(page) is loaded from database table by running sql query.
        Type Parameters:
        R -
        Parameters:
        ds -
        query - this query must be ordered by at least one key/id and has the result size limitation: for example LIMIT pageSize, ROWS FETCH NEXT pageSize ROWS ONLY
        pageSize -
        paramSetter - the second parameter is the result set for previous page. it's null for first page.
        resultExtractor -
        Returns:
      • queryByPage

        public static com.landawn.abacus.util.CheckedStream<com.landawn.abacus.util.DataSet,SQLException> queryByPage(Connection conn, String query, int pageSize, Jdbc.BiParametersSetter<? super AbstractQuery,com.landawn.abacus.util.DataSet> paramSetter)
        Runs a Stream with each element(page) is loaded from database table by running sql query.
        Parameters:
        conn -
        query - this query must be ordered by at least one key/id and has the result size limitation: for example LIMIT pageSize, ROWS FETCH NEXT pageSize ROWS ONLY
        pageSize -
        paramSetter - the second parameter is the result set for previous page. it's null for first page.
        Returns:
      • queryByPage

        public static <R> com.landawn.abacus.util.CheckedStream<R,SQLException> queryByPage(Connection conn, String query, int pageSize, Jdbc.BiParametersSetter<? super AbstractQuery,R> paramSetter, Jdbc.ResultExtractor<R> resultExtractor)
        Runs a Stream with each element(page) is loaded from database table by running sql query.
        Type Parameters:
        R -
        Parameters:
        conn -
        query - this query must be ordered by at least one key/id and has the result size limitation: for example LIMIT pageSize, ROWS FETCH NEXT pageSize ROWS ONLY
        pageSize -
        paramSetter - the second parameter is the result set for previous page. it's null for first page.
        resultExtractor - the second parameter is the result set for previous page. it's null for first page.
        Returns:
      • queryByPage

        public static <R> com.landawn.abacus.util.CheckedStream<R,SQLException> queryByPage(Connection conn, String query, int pageSize, Jdbc.BiParametersSetter<? super AbstractQuery,R> paramSetter, Jdbc.BiResultExtractor<R> resultExtractor)
        Runs a Stream with each element(page) is loaded from database table by running sql query.
        Type Parameters:
        R -
        Parameters:
        conn -
        query - this query must be ordered by at least one key/id and has the result size limitation: for example LIMIT pageSize, ROWS FETCH NEXT pageSize ROWS ONLY
        pageSize -
        paramSetter - the second parameter is the result set for previous page. it's null for first page.
        resultExtractor -
        Returns:
      • getOutParameters

        public static Jdbc.OutParamResult getOutParameters(CallableStatement stmt, List<Jdbc.OutParam> outParams) throws SQLException
        Parameters:
        stmt -
        outParams -
        Returns:
        Throws:
        SQLException
      • doesTableExist

        public static boolean doesTableExist(Connection conn, String tableName)
        Does table exist.
        Parameters:
        conn -
        tableName -
        Returns:
        true, if successful
      • createTableIfNotExists

        public static boolean createTableIfNotExists(Connection conn, String tableName, String schema)
        Returns true if succeed to create table, otherwise false is returned.
        Parameters:
        conn -
        tableName -
        schema -
        Returns:
        true, if successful
      • dropTableIfExists

        public static boolean dropTableIfExists(Connection conn, String tableName)
        Returns true if succeed to drop table, otherwise false is returned.
        Parameters:
        conn -
        tableName -
        Returns:
        true, if successful
      • getNamedParameters

        public static List<String> getNamedParameters(String sql)
        Gets the named parameters.
        Parameters:
        sql -
        Returns:
      • getDBSequence

        public static DBSequence getDBSequence(DataSource ds, String tableName, String seqName)
        Gets the DB sequence.
        Parameters:
        ds -
        tableName -
        seqName -
        Returns:
      • getDBSequence

        public static DBSequence getDBSequence(DataSource ds, String tableName, String seqName, long startVal, int seqBufferSize)
        Supports global sequence by db table.
        Parameters:
        ds -
        tableName -
        seqName -
        startVal -
        seqBufferSize - the numbers to allocate/reserve from database table when cached numbers are used up.
        Returns:
      • getDBLock

        public static DBLock getDBLock(DataSource ds, String tableName)
        Supports global lock by db table.
        Parameters:
        ds -
        tableName -
        Returns:
      • turnOffSqlLogGlobally

        public static void turnOffSqlLogGlobally()
      • turnOffSqlPerfLogGlobally

        public static void turnOffSqlPerfLogGlobally()
      • turnOffDaoMethodPerfLogGlobally

        public static void turnOffDaoMethodPerfLogGlobally()
      • enableSqlLog

        @Deprecated public static void enableSqlLog(boolean b)
        Deprecated.
        replaced by enableSqlLog/disableSqlLog.
        Enable/Disable sql log in current thread.
        Parameters:
        b - true to enable, false to disable.
      • enableSqlLog

        @Deprecated public static void enableSqlLog(boolean b, int maxSqlLogLength)
        Deprecated.
        replaced by enableSqlLog/disableSqlLog.
        Enable/Disable sql log in current thread.
        Parameters:
        b - true to enable, false to disable.
        maxSqlLogLength - default value is 1024
      • enableSqlLog

        public static void enableSqlLog()
        Enable sql log in current thread.
      • enableSqlLog

        public static void enableSqlLog(int maxSqlLogLength)
        Enable sql log in current thread.
        Parameters:
        maxSqlLogLength - default value is 1024
      • disableSqlLog

        public static void disableSqlLog()
        Disable sql log in current thread.
      • isSqlLogEnabled

        public static boolean isSqlLogEnabled()
        Checks if sql log is enabled or not in current thread.
        Returns:
        true if it's enabled, otherwise false is returned.
      • getSqlExtractor

        public static com.landawn.abacus.util.Throwables.Function<Statement,String,SQLException> getSqlExtractor()
        Returns:
      • setSqlExtractor

        public static void setSqlExtractor(com.landawn.abacus.util.Throwables.Function<Statement,String,SQLException> sqlExtractor)
        Parameters:
        sqlExtractor -
      • getSqlLogHandler

        public static com.landawn.abacus.util.function.TriConsumer<String,Long,Long> getSqlLogHandler()
        Returns:
      • setSqlLogHandler

        public static void setSqlLogHandler(com.landawn.abacus.util.function.TriConsumer<String,Long,Long> sqlLogHandler)
        Parameters:
        sqlLogHandler - 1st parameter is sql, 2nd parameter is start time of sql execution, 3rd parameter is end time of sql execution.
      • setMinExecutionTimeForSqlPerfLog

        public static void setMinExecutionTimeForSqlPerfLog(long minExecutionTimeForSqlPerfLog)
        Set minimum execution time to log sql performance in current thread.
        Parameters:
        minExecutionTimeForSqlPerfLog -
      • setMinExecutionTimeForSqlPerfLog

        public static void setMinExecutionTimeForSqlPerfLog(long minExecutionTimeForSqlPerfLog, int maxSqlLogLength)
        Set minimum execution time to log sql performance in current thread.
        Parameters:
        minExecutionTimeForSqlPerfLog - Default value is 1000 (milliseconds).
        maxSqlLogLength - default value is 1024
      • getMinExecutionTimeForSqlPerfLog

        public static long getMinExecutionTimeForSqlPerfLog()
        Return the minimum execution time in milliseconds to log SQL performance in current thread. Default value is 1000 (milliseconds).
        Returns:
      • disableSpringTransactional

        @Deprecated public static void disableSpringTransactional(boolean b)
        Deprecated.
        Don't share or share Spring Transactional in current thread. Spring Transactional won't be used in fetching Connection if it's disabled.
        Parameters:
        b - true to not share, false to share it again.
      • doNotUseSpringTransactional

        public static void doNotUseSpringTransactional(boolean b)
        Don't share or share Spring Transactional in current thread. Spring Transactional won't be used in fetching Connection if it's disabled.
        Parameters:
        b - true to not share, false to share it again.
      • isSpringTransactionalDisabled

        @Deprecated public static boolean isSpringTransactionalDisabled()
        Deprecated.
        Check if Spring Transactional is shared or not in current thread.
        Returns:
        true if it's not share, otherwise false is returned.
      • isSpringTransactionalNotUsed

        public static boolean isSpringTransactionalNotUsed()
        Check if Spring Transactional is shared or not in current thread.
        Returns:
        true if it's not share, otherwise false is returned.
      • runWithSqlLogDisabled

        public static <E extends Exception> void runWithSqlLogDisabled(com.landawn.abacus.util.Throwables.Runnable<E> sqlAction) throws E
        Since enable/disable sql log flag is attached with current thread, so don't execute the specified sqlAction in another thread.
        Type Parameters:
        E -
        Parameters:
        sqlAction -
        Throws:
        E
      • callWithSqlLogDisabled

        public static <R, E extends Exception> R callWithSqlLogDisabled(com.landawn.abacus.util.Throwables.Callable<R,E> sqlAction) throws E
        Since enable/disable sql log flag is attached with current thread, so don't execute the specified sqlAction in another thread.
        Type Parameters:
        R -
        E -
        Parameters:
        sqlAction -
        Returns:
        Throws:
        E
      • runWithoutUsingSpringTransaction

        public static <E extends Exception> void runWithoutUsingSpringTransaction(com.landawn.abacus.util.Throwables.Runnable<E> sqlAction) throws E
        Since using or not using Spring transaction flag is attached with current thread, so don't execute the specified sqlAction in another thread.
        Type Parameters:
        E -
        Parameters:
        sqlAction -
        Throws:
        E
      • callWithoutUsingSpringTransaction

        public static <R, E extends Exception> R callWithoutUsingSpringTransaction(com.landawn.abacus.util.Throwables.Callable<R,E> sqlAction) throws E
        Since using or not using Spring transaction flag is attached with current thread, so don't execute the specified sqlAction in another thread.
        Type Parameters:
        R -
        E -
        Parameters:
        sqlAction -
        Returns:
        Throws:
        E
      • run

        @Beta public static void run(com.landawn.abacus.util.Throwables.Runnable<Exception> sqlAction)
        Parameters:
        sqlAction -
      • run

        @Beta public static <T> void run(T t, com.landawn.abacus.util.Throwables.Consumer<? super T,Exception> sqlAction)
        Type Parameters:
        T -
        Parameters:
        t -
        sqlAction -
      • run

        @Beta public static <T, U> void run(T t, U u, com.landawn.abacus.util.Throwables.BiConsumer<? super T,? super U,Exception> sqlAction)
        Type Parameters:
        T -
        U -
        Parameters:
        t -
        u -
        sqlAction -
      • run

        @Beta public static <A, B, C> void run(A a, B b, C c, com.landawn.abacus.util.Throwables.TriConsumer<? super A,? super B,? super C,Exception> sqlAction)
        Type Parameters:
        A -
        B -
        C -
        Parameters:
        a -
        b -
        c -
        sqlAction -
      • call

        @Beta public static <R> R call(Callable<R> sqlAction)
        Type Parameters:
        R -
        Parameters:
        sqlAction -
        Returns:
      • call

        @Beta public static <T, R> R call(T t, com.landawn.abacus.util.Throwables.Function<? super T,? extends R,Exception> sqlAction)
        Type Parameters:
        T -
        R -
        Parameters:
        t -
        sqlAction -
        Returns:
      • call

        @Beta public static <T, U, R> R call(T t, U u, com.landawn.abacus.util.Throwables.BiFunction<? super T,? super U,? extends R,Exception> sqlAction)
        Type Parameters:
        T -
        U -
        R -
        Parameters:
        t -
        u -
        sqlAction -
        Returns:
      • call

        @Beta public static <A, B, C, R> R call(A a, B b, C c, com.landawn.abacus.util.Throwables.TriFunction<? super A,? super B,? super C,? extends R,Exception> sqlAction)
        Type Parameters:
        A -
        B -
        C -
        R -
        Parameters:
        a -
        b -
        c -
        sqlAction -
        Returns:
      • asyncRun

        @Beta public static com.landawn.abacus.util.ContinuableFuture<Void> asyncRun(com.landawn.abacus.util.Throwables.Runnable<Exception> sqlAction)
        Any transaction started in current thread won't be automatically applied to specified sqlAction which will be executed in another thread.
        Parameters:
        sqlAction -
        Returns:
      • asyncRun

        @Beta public static com.landawn.abacus.util.Tuple.Tuple2<com.landawn.abacus.util.ContinuableFuture<Void>,com.landawn.abacus.util.ContinuableFuture<Void>> asyncRun(com.landawn.abacus.util.Throwables.Runnable<Exception> sqlAction1, com.landawn.abacus.util.Throwables.Runnable<Exception> sqlAction2)
        Any transaction started in current thread won't be automatically applied to specified sqlAction which will be executed in another thread.
        Parameters:
        sqlAction1 -
        sqlAction2 -
        Returns:
      • asyncRun

        @Beta public static com.landawn.abacus.util.Tuple.Tuple3<com.landawn.abacus.util.ContinuableFuture<Void>,com.landawn.abacus.util.ContinuableFuture<Void>,com.landawn.abacus.util.ContinuableFuture<Void>> asyncRun(com.landawn.abacus.util.Throwables.Runnable<Exception> sqlAction1, com.landawn.abacus.util.Throwables.Runnable<Exception> sqlAction2, com.landawn.abacus.util.Throwables.Runnable<Exception> sqlAction3)
        Any transaction started in current thread won't be automatically applied to specified sqlAction which will be executed in another thread.
        Parameters:
        sqlAction1 -
        sqlAction2 -
        sqlAction3 -
        Returns:
      • asyncRun

        @Beta public static <T> com.landawn.abacus.util.ContinuableFuture<Void> asyncRun(T t, com.landawn.abacus.util.Throwables.Consumer<? super T,Exception> sqlAction)
        Any transaction started in current thread won't be automatically applied to specified sqlAction which will be executed in another thread.
        Type Parameters:
        T -
        Parameters:
        t -
        sqlAction -
        Returns:
      • asyncRun

        @Beta public static <T, U> com.landawn.abacus.util.ContinuableFuture<Void> asyncRun(T t, U u, com.landawn.abacus.util.Throwables.BiConsumer<? super T,? super U,Exception> sqlAction)
        Any transaction started in current thread won't be automatically applied to specified sqlAction which will be executed in another thread.
        Type Parameters:
        T -
        U -
        Parameters:
        t -
        u -
        sqlAction -
        Returns:
      • asyncRun

        @Beta public static <A, B, C> com.landawn.abacus.util.ContinuableFuture<Void> asyncRun(A a, B b, C c, com.landawn.abacus.util.Throwables.TriConsumer<? super A,? super B,? super C,Exception> sqlAction)
        Any transaction started in current thread won't be automatically applied to specified sqlAction which will be executed in another thread.
        Type Parameters:
        A -
        B -
        C -
        Parameters:
        a -
        b -
        c -
        sqlAction -
        Returns:
      • asyncCall

        @Beta public static <R> com.landawn.abacus.util.ContinuableFuture<R> asyncCall(Callable<R> sqlAction)
        Any transaction started in current thread won't be automatically applied to specified sqlAction which will be executed in another thread.
        Type Parameters:
        R -
        Parameters:
        sqlAction -
        Returns:
      • asyncCall

        @Beta public static <R1, R2> com.landawn.abacus.util.Tuple.Tuple2<com.landawn.abacus.util.ContinuableFuture<R1>,com.landawn.abacus.util.ContinuableFuture<R2>> asyncCall(Callable<R1> sqlAction1, Callable<R2> sqlAction2)
        Any transaction started in current thread won't be automatically applied to specified sqlAction which will be executed in another thread.
        Type Parameters:
        R1 -
        R2 -
        Parameters:
        sqlAction1 -
        sqlAction2 -
        Returns:
      • asyncCall

        @Beta public static <R1, R2, R3> com.landawn.abacus.util.Tuple.Tuple3<com.landawn.abacus.util.ContinuableFuture<R1>,com.landawn.abacus.util.ContinuableFuture<R2>,com.landawn.abacus.util.ContinuableFuture<R3>> asyncCall(Callable<R1> sqlAction1, Callable<R2> sqlAction2, Callable<R3> sqlAction3)
        Any transaction started in current thread won't be automatically applied to specified sqlAction which will be executed in another thread.
        Type Parameters:
        R1 -
        R2 -
        R3 -
        Parameters:
        sqlAction1 -
        sqlAction2 -
        sqlAction3 -
        Returns:
      • asyncCall

        @Beta public static <T, R> com.landawn.abacus.util.ContinuableFuture<R> asyncCall(T t, com.landawn.abacus.util.Throwables.Function<? super T,? extends R,Exception> sqlAction)
        Any transaction started in current thread won't be automatically applied to specified sqlAction which will be executed in another thread.
        Type Parameters:
        T -
        R -
        Parameters:
        t -
        sqlAction -
        Returns:
      • asyncCall

        @Beta public static <T, U, R> com.landawn.abacus.util.ContinuableFuture<R> asyncCall(T t, U u, com.landawn.abacus.util.Throwables.BiFunction<? super T,? super U,? extends R,Exception> sqlAction)
        Any transaction started in current thread won't be automatically applied to specified sqlAction which will be executed in another thread.
        Type Parameters:
        T -
        U -
        R -
        Parameters:
        t -
        u -
        sqlAction -
        Returns:
      • asyncCall

        @Beta public static <A, B, C, R> com.landawn.abacus.util.ContinuableFuture<R> asyncCall(A a, B b, C c, com.landawn.abacus.util.Throwables.TriFunction<? super A,? super B,? super C,? extends R,Exception> sqlAction)
        Any transaction started in current thread won't be automatically applied to specified sqlAction which will be executed in another thread.
        Type Parameters:
        A -
        B -
        C -
        R -
        Parameters:
        a -
        b -
        c -
        sqlAction -
        Returns:
      • setIdExtractorForDao

        public static <T, ID, SB extends com.landawn.abacus.util.SQLBuilder, TD extends CrudDao<T, ID, SB, TD>> void setIdExtractorForDao(Class<? extends CrudDao<T,ID,SB,TD>> daoInterface, Jdbc.RowMapper<? extends ID> idExtractor)
        Type Parameters:
        T -
        ID -
        SB -
        TD -
        Parameters:
        daoInterface -
        idExtractor -
      • setIdExtractorForDao

        public static <T, ID, SB extends com.landawn.abacus.util.SQLBuilder, TD extends CrudDao<T, ID, SB, TD>> void setIdExtractorForDao(Class<? extends CrudDao<T,ID,SB,TD>> daoInterface, Jdbc.BiRowMapper<? extends ID> idExtractor)
        Type Parameters:
        T -
        ID -
        SB -
        TD -
        Parameters:
        daoInterface -
        idExtractor -
      • createDao

        public static <TD extends Dao> TD createDao(Class<TD> daoInterface, DataSource ds)
        Type Parameters:
        TD -
        Parameters:
        daoInterface -
        ds -
        Returns:
      • createDao

        public static <TD extends Dao> TD createDao(Class<TD> daoInterface, DataSource ds, com.landawn.abacus.util.SQLMapper sqlMapper)
        Type Parameters:
        TD -
        Parameters:
        daoInterface -
        ds -
        sqlMapper -
        Returns:
      • createDao

        @Deprecated public static <TD extends Dao> TD createDao(Class<TD> daoInterface, DataSource ds, com.landawn.abacus.util.SQLMapper sqlMapper, com.landawn.abacus.cache.Cache<String,Object> cache)
        Deprecated.
        Type Parameters:
        TD -
        Parameters:
        daoInterface -
        ds -
        sqlMapper -
        cache - It's better to not share cache between Dao instances.
        Returns:
      • createDao

        public static <TD extends Dao> TD createDao(Class<TD> daoInterface, DataSource ds, Executor executor)
        Type Parameters:
        TD -
        Parameters:
        daoInterface -
        ds -
        executor -
        Returns:
      • createDao

        public static <TD extends Dao> TD createDao(Class<TD> daoInterface, DataSource ds, com.landawn.abacus.util.SQLMapper sqlMapper, Executor executor)
        Type Parameters:
        TD -
        Parameters:
        daoInterface -
        ds -
        sqlMapper -
        executor -
        Returns:
      • createDao

        @Deprecated public static <TD extends Dao> TD createDao(Class<TD> daoInterface, DataSource ds, com.landawn.abacus.util.SQLMapper sqlMapper, com.landawn.abacus.cache.Cache<String,Object> cache, Executor executor)
        Deprecated.
        Type Parameters:
        TD -
        Parameters:
        daoInterface -
        ds -
        sqlMapper -
        cache - It's better to not share cache between Dao instances.
        executor -
        Returns:
      • createDao

        public static <TD extends Dao> TD createDao(Class<TD> daoInterface, String targetTableName, DataSource ds)
        Type Parameters:
        TD -
        Parameters:
        daoInterface -
        targetTableName -
        ds -
        Returns:
      • createDao

        public static <TD extends Dao> TD createDao(Class<TD> daoInterface, String targetTableName, DataSource ds, com.landawn.abacus.util.SQLMapper sqlMapper)
        Type Parameters:
        TD -
        Parameters:
        daoInterface -
        targetTableName -
        ds -
        sqlMapper -
        Returns:
      • createDao

        @Deprecated public static <TD extends Dao> TD createDao(Class<TD> daoInterface, String targetTableName, DataSource ds, com.landawn.abacus.util.SQLMapper sqlMapper, com.landawn.abacus.cache.Cache<String,Object> cache)
        Deprecated.
        Type Parameters:
        TD -
        Parameters:
        daoInterface -
        targetTableName -
        ds -
        sqlMapper -
        cache - It's better to not share cache between Dao instances.
        Returns:
      • createDao

        public static <TD extends Dao> TD createDao(Class<TD> daoInterface, String targetTableName, DataSource ds, Executor executor)
        Type Parameters:
        TD -
        Parameters:
        daoInterface -
        targetTableName -
        ds -
        executor -
        Returns:
      • createDao

        public static <TD extends Dao> TD createDao(Class<TD> daoInterface, String targetTableName, DataSource ds, com.landawn.abacus.util.SQLMapper sqlMapper, Executor executor)
        Type Parameters:
        TD -
        Parameters:
        daoInterface -
        targetTableName -
        ds -
        sqlMapper -
        executor -
        Returns:
      • createDao

        @Deprecated public static <TD extends Dao> TD createDao(Class<TD> daoInterface, String targetTableName, DataSource ds, com.landawn.abacus.util.SQLMapper sqlMapper, com.landawn.abacus.cache.Cache<String,Object> cache, Executor executor)
        Deprecated.
        Type Parameters:
        TD -
        Parameters:
        daoInterface -
        targetTableName -
        ds -
        sqlMapper -
        cache - It's better to not share cache between Dao instances.
        executor -
        Returns:
      • generateEntityClass

        public static String generateEntityClass(DataSource ds, String tableName)
        Parameters:
        ds -
        tableName -
        Returns:
      • generateEntityClass

        public static String generateEntityClass(DataSource ds, String tableName, EntityCodeConfig config)
        Parameters:
        ds -
        tableName -
        config -
        Returns:
      • generateEntityClass

        public static String generateEntityClass(Connection conn, String tableName)
        Parameters:
        conn -
        tableName -
        Returns:
      • generateEntityClass

        public static String generateEntityClass(Connection conn, String tableName, EntityCodeConfig config)
        Parameters:
        conn -
        tableName -
        config -
        Returns:
      • generateEntityClass

        public static String generateEntityClass(DataSource ds, String entityName, String query)
        Parameters:
        ds -
        entityName -
        query -
        Returns:
      • generateEntityClass

        public static String generateEntityClass(DataSource ds, String entityName, String query, EntityCodeConfig config)
        Parameters:
        ds -
        entityName -
        query -
        config -
        Returns:
      • generateEntityClass

        public static String generateEntityClass(Connection conn, String entityName, String query)
        Parameters:
        conn -
        entityName -
        query -
        Returns:
      • generateEntityClass

        public static String generateEntityClass(Connection conn, String entityName, String query, EntityCodeConfig config)
        Parameters:
        conn -
        entityName -
        query -
        config -
        Returns:
      • generateSelectSql

        public static String generateSelectSql(DataSource dataSource, String tableName) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        dataSource -
        tableName -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException
      • generateSelectSql

        public static String generateSelectSql(Connection conn, String tableName)
        Parameters:
        conn -
        tableName -
        Returns:
      • generateInsertSql

        public static String generateInsertSql(DataSource dataSource, String tableName) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        dataSource -
        tableName -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException
      • generateInsertSql

        public static String generateInsertSql(Connection conn, String tableName)
        Parameters:
        conn -
        tableName -
        Returns:
      • generateNamedInsertSql

        public static String generateNamedInsertSql(DataSource dataSource, String tableName) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        dataSource -
        tableName -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException
      • generateNamedInsertSql

        public static String generateNamedInsertSql(Connection conn, String tableName)
        Parameters:
        conn -
        tableName -
        Returns:
      • generateUpdateSql

        public static String generateUpdateSql(DataSource dataSource, String tableName) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        dataSource -
        tableName -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException
      • generateUpdateSql

        public static String generateUpdateSql(Connection conn, String tableName)
        Parameters:
        conn -
        tableName -
        Returns:
      • generateNamedUpdateSql

        public static String generateNamedUpdateSql(DataSource dataSource, String tableName) throws com.landawn.abacus.exception.UncheckedSQLException
        Parameters:
        dataSource -
        tableName -
        Returns:
        Throws:
        com.landawn.abacus.exception.UncheckedSQLException
      • generateNamedUpdateSql

        public static String generateNamedUpdateSql(Connection conn, String tableName)
        Parameters:
        conn -
        tableName -
        Returns:
      • getInsertPropNames

        public static Collection<String> getInsertPropNames(Object entity)
        Parameters:
        entity -
        Returns:
      • getInsertPropNames

        public static Collection<String> getInsertPropNames(Object entity, Set<String> excludedPropNames)
        Parameters:
        entity -
        excludedPropNames -
        Returns:
      • getInsertPropNames

        public static Collection<String> getInsertPropNames(Class<?> entityClass)
        Parameters:
        entityClass -
        Returns:
      • getInsertPropNames

        public static Collection<String> getInsertPropNames(Class<?> entityClass, Set<String> excludedPropNames)
        Parameters:
        entityClass -
        excludedPropNames -
        Returns:
      • getSelectPropNames

        public static Collection<String> getSelectPropNames(Class<?> entityClass)
        Parameters:
        entityClass -
        Returns:
      • getSelectPropNames

        public static Collection<String> getSelectPropNames(Class<?> entityClass, Set<String> excludedPropNames)
        Parameters:
        entityClass -
        excludedPropNames -
        Returns:
      • getSelectPropNames

        public static Collection<String> getSelectPropNames(Class<?> entityClass, boolean includeSubEntityProperties, Set<String> excludedPropNames)
        Parameters:
        entityClass -
        includeSubEntityProperties -
        excludedPropNames -
        Returns:
      • getUpdatePropNames

        public static Collection<String> getUpdatePropNames(Class<?> entityClass)
        Parameters:
        entityClass -
        Returns:
      • getUpdatePropNames

        public static Collection<String> getUpdatePropNames(Class<?> entityClass, Set<String> excludedPropNames)
        Parameters:
        entityClass -
        excludedPropNames -
        Returns:
      • blob2String

        public static String blob2String(Blob blob) throws SQLException
        Parameters:
        blob -
        Returns:
        Throws:
        SQLException
      • blob2String

        public static String blob2String(Blob blob, Charset charset) throws SQLException
        Parameters:
        blob -
        charset -
        Returns:
        Throws:
        SQLException
      • writeBlobToFile

        public static long writeBlobToFile(Blob blob, File output) throws SQLException, IOException
        Parameters:
        blob -
        output -
        Returns:
        Throws:
        SQLException
        IOException
      • isNullOrDefault

        public static boolean isNullOrDefault(Object value)
        Parameters:
        value -
        Returns: