org.apache.commons.dbcp2

## Class PoolablePreparedStatement<K>

- java.lang.Object
- - org.apache.commons.dbcp2.AbandonedTrace
  - - org.apache.commons.dbcp2.DelegatingStatement
    - - org.apache.commons.dbcp2.DelegatingPreparedStatement
      - - org.apache.commons.dbcp2.PoolablePreparedStatement<K>

- Type Parameters:
    `K` - the key type
  All Implemented Interfaces:
    AutoCloseable, PreparedStatement, Statement, Wrapper, TrackedUse

      public class PoolablePreparedStatement<K>
      extends DelegatingPreparedStatement

  A `DelegatingPreparedStatement` that cooperates with `PoolingConnection` to implement a pool of `PreparedStatement`s.

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

  Since:
    2.0
  Author:
    Rodney Waldhoff, Glenn L. Nielsen, James House, Dirk Verbeeck
  See Also:
    `PoolingConnection`

- - ### Field Summary

    - ### Fields inherited from interface java.sql.Statement

      `CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PoolablePreparedStatement(PreparedStatement stmt, K key, KeyedObjectPool<K,PoolablePreparedStatement<K>> pool, DelegatingConnection<?> conn)` Constructor

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `activate()`
    `void` | `addBatch()` Add batch.
    `void` | `clearBatch()` Clear Batch.
    `void` | `close()` Return me to my pool.
    `void` | `passivate()`

    - ### Methods inherited from class org.apache.commons.dbcp2.DelegatingPreparedStatement

      `clearParameters, execute, executeQuery, executeUpdate, getMetaData, getParameterMetaData, setArray, setAsciiStream, setAsciiStream, setAsciiStream, setBigDecimal, setBinaryStream, setBinaryStream, setBinaryStream, setBlob, setBlob, setBlob, setBoolean, setByte, setBytes, setCharacterStream, setCharacterStream, setCharacterStream, setClob, setClob, setClob, setDate, setDate, setDouble, setFloat, setInt, setLong, setNCharacterStream, setNCharacterStream, setNClob, setNClob, setNClob, setNString, setNull, setNull, setObject, setObject, setObject, setRef, setRowId, setShort, setSQLXML, setString, setTime, setTime, setTimestamp, setTimestamp, setUnicodeStream, setURL, toString`

    - ### Methods inherited from class org.apache.commons.dbcp2.DelegatingStatement

      `addBatch, cancel, checkOpen, clearWarnings, closeOnCompletion, execute, execute, execute, execute, executeBatch, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, finalize, getConnection, getConnectionInternal, getDelegate, getFetchDirection, getFetchSize, getGeneratedKeys, getInnermostDelegate, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, handleException, isClosed, isClosedInternal, isCloseOnCompletion, isPoolable, isWrapperFor, setClosedInternal, setCursorName, setDelegate, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout, unwrap`

    - ### Methods inherited from class org.apache.commons.dbcp2.AbandonedTrace

      `addTrace, clearTrace, getLastUsed, getTrace, removeTrace, setLastUsed, setLastUsed`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.sql.Statement

      `addBatch, cancel, clearWarnings, closeOnCompletion, execute, execute, execute, execute, executeBatch, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout`

    - ### Methods inherited from interface java.sql.Wrapper

      `isWrapperFor, unwrap`

- - ### Constructor Detail

    - #### PoolablePreparedStatement

          public PoolablePreparedStatement(PreparedStatement stmt,
                                   K key,
                                   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 SQLException

      Add batch.
      Specified by:
        `addBatch` in interface `PreparedStatement`
      Overrides:
        `addBatch` in class `DelegatingPreparedStatement`
      Throws:
        `SQLException`

    - #### clearBatch

          public void clearBatch()
                          throws SQLException

      Clear Batch.
      Specified by:
        `clearBatch` in interface `Statement`
      Overrides:
        `clearBatch` in class `DelegatingStatement`
      Throws:
        `SQLException`

    - #### close

          public void close()
                     throws SQLException

      Return me to my pool.
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `Statement`
      Overrides:
        `close` in class `DelegatingStatement`
      Throws:
        `SQLException`

    - #### activate

          public void activate()
                        throws SQLException

      Overrides:
        `activate` in class `DelegatingStatement`
      Throws:
        `SQLException`

    - #### passivate

          public void passivate()
                         throws SQLException

      Overrides:
        `passivate` in class `DelegatingStatement`
      Throws:
        `SQLException`

Copyright © 2001–2017 The Apache Software Foundation. All rights reserved.