Class PoolablePreparedStatement

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.sql.PreparedStatement, java.sql.Statement, java.sql.Wrapper

    public class PoolablePreparedStatement
    extends DelegatingPreparedStatement
    implements java.sql.PreparedStatement
    A DelegatingPreparedStatement that cooperates with PoolingConnection to implement a pool of PreparedStatements.

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

    Version:
    $Revision: 745860 $ $Date: 2009-02-19 08:45:07 -0500 (Thu, 19 Feb 2009) $
    Author:
    Rodney Waldhoff, Glenn L. Nielsen, James House, Dirk Verbeeck
    See Also:
    PoolingConnection
    • Field Detail

      • _pool

        protected org.apache.commons.pool.KeyedObjectPool _pool
        The KeyedObjectPool from which I was obtained.
      • _key

        protected java.lang.Object _key
        My "key" as used by KeyedObjectPool.
    • Constructor Detail

      • PoolablePreparedStatement

        public PoolablePreparedStatement​(java.sql.PreparedStatement stmt,
                                         java.lang.Object key,
                                         org.apache.commons.pool.KeyedObjectPool pool,
                                         java.sql.Connection 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

        protected void activate()
                         throws java.sql.SQLException
        Overrides:
        activate in class DelegatingStatement
        Throws:
        java.sql.SQLException
      • passivate

        protected void passivate()
                          throws java.sql.SQLException
        Overrides:
        passivate in class DelegatingStatement
        Throws:
        java.sql.SQLException
      • isCloseOnCompletion

        public boolean isCloseOnCompletion()
                                    throws java.sql.SQLException
        Specified by:
        isCloseOnCompletion in interface java.sql.Statement
        Overrides:
        isCloseOnCompletion in class DelegatingPreparedStatement
        Throws:
        java.sql.SQLException
      • closeOnCompletion

        public void closeOnCompletion()
                               throws java.sql.SQLException
        Specified by:
        closeOnCompletion in interface java.sql.Statement
        Overrides:
        closeOnCompletion in class DelegatingPreparedStatement
        Throws:
        java.sql.SQLException