Class PoolingConnection

    • Constructor Detail

      • PoolingConnection

        public PoolingConnection​(java.sql.Connection connection)
        Constructor.
        Parameters:
        connection - the underlying Connection.
    • Method Detail

      • close

        public void close()
                   throws java.sql.SQLException
        Closes and frees all PreparedStatements or CallableStatements from the pool, and close the underlying connection.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.sql.Connection
        Overrides:
        close in class DelegatingConnection<java.sql.Connection>
        Throws:
        java.sql.SQLException
      • connectionReturnedToPool

        public void connectionReturnedToPool()
                                      throws java.sql.SQLException
        Notification from PoolableConnection that we returned to the pool.
        Throws:
        java.sql.SQLException - when clearStatementPoolOnReturn is true and the statement pool could not be cleared
        Since:
        2.8.0
      • createKey

        protected PStmtKey createKey​(java.lang.String sql)
        Creates a PStmtKey for the given arguments.
        Parameters:
        sql - the SQL string used to define the statement
        Returns:
        the PStmtKey created for the given arguments.
      • createKey

        protected PStmtKey createKey​(java.lang.String sql,
                                     int autoGeneratedKeys)
        Creates a PStmtKey for the given arguments.
        Parameters:
        sql - the SQL string used to define the statement
        autoGeneratedKeys - A flag indicating whether auto-generated keys should be returned; one of Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS.
        Returns:
        the PStmtKey created for the given arguments.
      • createKey

        protected PStmtKey createKey​(java.lang.String sql,
                                     int resultSetType,
                                     int resultSetConcurrency)
        Creates a PStmtKey for the given arguments.
        Parameters:
        sql - the SQL string used to define the statement
        resultSetType - result set type
        resultSetConcurrency - result set concurrency
        Returns:
        the PStmtKey created for the given arguments.
      • createKey

        protected PStmtKey createKey​(java.lang.String sql,
                                     int resultSetType,
                                     int resultSetConcurrency,
                                     int resultSetHoldability)
        Creates a PStmtKey for the given arguments.
        Parameters:
        sql - the SQL string used to define the statement
        resultSetType - result set type
        resultSetConcurrency - result set concurrency
        resultSetHoldability - result set holdability
        Returns:
        the PStmtKey created for the given arguments.
      • createKey

        protected PStmtKey createKey​(java.lang.String sql,
                                     int resultSetType,
                                     int resultSetConcurrency,
                                     int resultSetHoldability,
                                     PoolingConnection.StatementType statementType)
        Creates a PStmtKey for the given arguments.
        Parameters:
        sql - the SQL string used to define the statement
        resultSetType - result set type
        resultSetConcurrency - result set concurrency
        resultSetHoldability - result set holdability
        statementType - statement type
        Returns:
        the PStmtKey created for the given arguments.
      • createKey

        protected PStmtKey createKey​(java.lang.String sql,
                                     int resultSetType,
                                     int resultSetConcurrency,
                                     PoolingConnection.StatementType statementType)
        Creates a PStmtKey for the given arguments.
        Parameters:
        sql - the SQL string used to define the statement
        resultSetType - result set type
        resultSetConcurrency - result set concurrency
        statementType - statement type
        Returns:
        the PStmtKey created for the given arguments.
      • createKey

        protected PStmtKey createKey​(java.lang.String sql,
                                     int[] columnIndexes)
        Creates a PStmtKey for the given arguments.
        Parameters:
        sql - the SQL string used to define the statement
        columnIndexes - An array of column indexes indicating the columns that should be returned from the inserted row or rows.
        Returns:
        the PStmtKey created for the given arguments.
      • createKey

        protected PStmtKey createKey​(java.lang.String sql,
                                     PoolingConnection.StatementType statementType)
        Creates a PStmtKey for the given arguments.
        Parameters:
        sql - the SQL string used to define the statement
        statementType - statement type
        Returns:
        the PStmtKey created for the given arguments.
      • createKey

        protected PStmtKey createKey​(java.lang.String sql,
                                     java.lang.String[] columnNames)
        Creates a PStmtKey for the given arguments.
        Parameters:
        sql - the SQL string used to define the statement
        columnNames - column names
        Returns:
        the PStmtKey created for the given arguments.
      • normalizeSQL

        protected java.lang.String normalizeSQL​(java.lang.String sql)
        Normalizes the given SQL statement, producing a canonical form that is semantically equivalent to the original.
        Parameters:
        sql - The statement to be normalized.
        Returns:
        The canonical form of the supplied SQL statement.
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String sql)
                                               throws java.sql.SQLException
        Creates or obtains a CallableStatement from the pool.
        Specified by:
        prepareCall in interface java.sql.Connection
        Overrides:
        prepareCall in class DelegatingConnection<java.sql.Connection>
        Parameters:
        sql - the SQL string used to define the CallableStatement
        Returns:
        a PoolableCallableStatement
        Throws:
        java.sql.SQLException - Wraps an underlying exception.
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String sql,
                                                      int resultSetType,
                                                      int resultSetConcurrency)
                                               throws java.sql.SQLException
        Creates or obtains a CallableStatement from the pool.
        Specified by:
        prepareCall in interface java.sql.Connection
        Overrides:
        prepareCall in class DelegatingConnection<java.sql.Connection>
        Parameters:
        sql - the SQL string used to define the CallableStatement
        resultSetType - result set type
        resultSetConcurrency - result set concurrency
        Returns:
        a PoolableCallableStatement
        Throws:
        java.sql.SQLException - Wraps an underlying exception.
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String sql,
                                                      int resultSetType,
                                                      int resultSetConcurrency,
                                                      int resultSetHoldability)
                                               throws java.sql.SQLException
        Creates or obtains a CallableStatement from the pool.
        Specified by:
        prepareCall in interface java.sql.Connection
        Overrides:
        prepareCall in class DelegatingConnection<java.sql.Connection>
        Parameters:
        sql - the SQL string used to define the CallableStatement
        resultSetType - result set type
        resultSetConcurrency - result set concurrency
        resultSetHoldability - result set holdability
        Returns:
        a PoolableCallableStatement
        Throws:
        java.sql.SQLException - Wraps an underlying exception.
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql)
                                                    throws java.sql.SQLException
        Creates or obtains a PreparedStatement from the pool.
        Specified by:
        prepareStatement in interface java.sql.Connection
        Overrides:
        prepareStatement in class DelegatingConnection<java.sql.Connection>
        Parameters:
        sql - the SQL string used to define the PreparedStatement
        Returns:
        a PoolablePreparedStatement
        Throws:
        java.sql.SQLException - Wraps an underlying exception.
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int autoGeneratedKeys)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Overrides:
        prepareStatement in class DelegatingConnection<java.sql.Connection>
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int resultSetType,
                                                           int resultSetConcurrency)
                                                    throws java.sql.SQLException
        Creates or obtains a PreparedStatement from the pool.
        Specified by:
        prepareStatement in interface java.sql.Connection
        Overrides:
        prepareStatement in class DelegatingConnection<java.sql.Connection>
        Parameters:
        sql - the SQL string used to define the PreparedStatement
        resultSetType - result set type
        resultSetConcurrency - result set concurrency
        Returns:
        a PoolablePreparedStatement
        Throws:
        java.sql.SQLException - Wraps an underlying exception.
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int resultSetType,
                                                           int resultSetConcurrency,
                                                           int resultSetHoldability)
                                                    throws java.sql.SQLException
        Creates or obtains a PreparedStatement from the pool.
        Specified by:
        prepareStatement in interface java.sql.Connection
        Overrides:
        prepareStatement in class DelegatingConnection<java.sql.Connection>
        Parameters:
        sql - the SQL string used to define the PreparedStatement
        resultSetType - result set type
        resultSetConcurrency - result set concurrency
        resultSetHoldability - result set holdability
        Returns:
        a PoolablePreparedStatement
        Throws:
        java.sql.SQLException - Wraps an underlying exception.
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int[] columnIndexes)
                                                    throws java.sql.SQLException
        Creates or obtains a PreparedStatement from the pool.
        Specified by:
        prepareStatement in interface java.sql.Connection
        Overrides:
        prepareStatement in class DelegatingConnection<java.sql.Connection>
        Parameters:
        sql - the SQL string used to define the PreparedStatement
        columnIndexes - An array of column indexes indicating the columns that should be returned from the inserted row or rows.
        Returns:
        a PoolablePreparedStatement
        Throws:
        java.sql.SQLException - Wraps an underlying exception.
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           java.lang.String[] columnNames)
                                                    throws java.sql.SQLException
        Creates or obtains a PreparedStatement from the pool.
        Specified by:
        prepareStatement in interface java.sql.Connection
        Overrides:
        prepareStatement in class DelegatingConnection<java.sql.Connection>
        Parameters:
        sql - the SQL string used to define the PreparedStatement
        columnNames - column names
        Returns:
        a PoolablePreparedStatement
        Throws:
        java.sql.SQLException - Wraps an underlying exception.
      • setClearStatementPoolOnReturn

        public void setClearStatementPoolOnReturn​(boolean clearStatementPoolOnReturn)
        Sets whether the pool of statements should be cleared when the connection is returned to its pool. Default is false.
        Parameters:
        clearStatementPoolOnReturn - clear or not
        Since:
        2.8.0
      • toString

        public java.lang.String toString()
        Description copied from class: DelegatingConnection
        Returns a string representation of the metadata associated with the innermost delegate connection.
        Overrides:
        toString in class DelegatingConnection<java.sql.Connection>