Class PoolablePreparedStatement<K>

  • Type Parameters:
    K - the key type
    All Implemented Interfaces:
    java.lang.AutoCloseable, java.sql.PreparedStatement, java.sql.Statement, java.sql.Wrapper, org.apache.commons.pool2.TrackedUse

    public class PoolablePreparedStatement<K>
    extends DelegatingPreparedStatement
    A DelegatingPreparedStatement that cooperates with PoolingConnection to implement a pool of PreparedStatements.

    My close() method returns me to my containing pool. (See PoolingConnection.)

    Since:
    2.0
    Version:
    $Id: PoolablePreparedStatement.java 1649430 2015-01-04 21:29:32Z tn $
    Author:
    Rodney Waldhoff, Glenn L. Nielsen, James House, Dirk Verbeeck
    See Also:
    PoolingConnection
    • Constructor Detail

      • PoolablePreparedStatement

        public PoolablePreparedStatement​(java.sql.PreparedStatement stmt,
                                         K key,
                                         org.apache.commons.pool2.KeyedObjectPool<K,​PoolablePreparedStatement<K>> pool,
                                         DelegatingConnection<?> conn)
        Constructor
        Parameters:
        stmt - my underlying PreparedStatement
        key - my key" as used by KeyedObjectPool
        pool - the KeyedObjectPool from which I was obtained.
        conn - the Connection from which I was created
    • Method Detail

      • addBatch

        public void addBatch()
                      throws java.sql.SQLException
        Add batch.
        Specified by:
        addBatch in interface java.sql.PreparedStatement
        Overrides:
        addBatch in class DelegatingPreparedStatement
        Throws:
        java.sql.SQLException
      • clearBatch

        public void clearBatch()
                        throws java.sql.SQLException
        Clear Batch.
        Specified by:
        clearBatch in interface java.sql.Statement
        Overrides:
        clearBatch in class DelegatingStatement
        Throws:
        java.sql.SQLException
      • close

        public void close()
                   throws java.sql.SQLException
        Return me to my pool.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.sql.Statement
        Overrides:
        close in class DelegatingStatement
        Throws:
        java.sql.SQLException
      • activate

        public void activate()
                      throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • passivate

        public void passivate()
                       throws java.sql.SQLException
        Throws:
        java.sql.SQLException