Class PoolingConnection

    • Constructor Detail

      • PoolingConnection

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

      • close

        public void close()
                   throws java.sql.SQLException
        Close and free 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
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql)
                                                    throws java.sql.SQLException
        Create or obtain 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
      • 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
        Create or obtain 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
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String sql)
                                               throws java.sql.SQLException
        Create or obtain 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
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String sql,
                                                      int resultSetType,
                                                      int resultSetConcurrency)
                                               throws java.sql.SQLException
        Create or obtain 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
      • destroyObject

        public void destroyObject​(PStmtKey key,
                                  org.apache.commons.pool2.PooledObject<DelegatingPreparedStatement> p)
                           throws java.lang.Exception
        KeyedPooledObjectFactory method for destroying PoolablePreparedStatements and PoolableCallableStatements. Closes the underlying statement.
        Specified by:
        destroyObject in interface org.apache.commons.pool2.KeyedPooledObjectFactory<PStmtKey,​DelegatingPreparedStatement>
        Parameters:
        key - ignored
        p - the wrapped pooled statement to be destroyed.
        Throws:
        java.lang.Exception
      • validateObject

        public boolean validateObject​(PStmtKey key,
                                      org.apache.commons.pool2.PooledObject<DelegatingPreparedStatement> p)
        KeyedPooledObjectFactory method for validating pooled statements. Currently always returns true.
        Specified by:
        validateObject in interface org.apache.commons.pool2.KeyedPooledObjectFactory<PStmtKey,​DelegatingPreparedStatement>
        Parameters:
        key - ignored
        p - ignored
        Returns:
        true
      • activateObject

        public void activateObject​(PStmtKey key,
                                   org.apache.commons.pool2.PooledObject<DelegatingPreparedStatement> p)
                            throws java.lang.Exception
        KeyedPooledObjectFactory method for activating pooled statements.
        Specified by:
        activateObject in interface org.apache.commons.pool2.KeyedPooledObjectFactory<PStmtKey,​DelegatingPreparedStatement>
        Parameters:
        key - ignored
        p - wrapped pooled statement to be activated
        Throws:
        java.lang.Exception
      • passivateObject

        public void passivateObject​(PStmtKey key,
                                    org.apache.commons.pool2.PooledObject<DelegatingPreparedStatement> p)
                             throws java.lang.Exception
        KeyedPooledObjectFactory method for passivating PreparedStatements or CallableStatements. Invokes PreparedStatement.clearParameters().
        Specified by:
        passivateObject in interface org.apache.commons.pool2.KeyedPooledObjectFactory<PStmtKey,​DelegatingPreparedStatement>
        Parameters:
        key - ignored
        p - a wrapped PreparedStatement
        Throws:
        java.lang.Exception
      • 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>