org.apache.tomcat.dbcp.dbcp

## Class PoolableConnection

- java.lang.Object
- - org.apache.tomcat.dbcp.dbcp.AbandonedTrace
  - - org.apache.tomcat.dbcp.dbcp.DelegatingConnection
    - - org.apache.tomcat.dbcp.dbcp.PoolableConnection

- All Implemented Interfaces:
    java.lang.AutoCloseable, java.sql.Connection, java.sql.Wrapper

      public class PoolableConnection
      extends DelegatingConnection

  A delegating connection that, rather than closing the underlying connection, returns itself to an `ObjectPool` when closed.
  Author:
    Rodney Waldhoff, Glenn L. Nielsen, James House

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ObjectPool<PoolableConnection>` | `_pool` The pool to which I should return.

    - ### Fields inherited from class org.apache.tomcat.dbcp.dbcp.DelegatingConnection

      `_closed, _conn`

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

      `TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PoolableConnection(java.sql.Connection conn, ObjectPool<PoolableConnection> pool)`
    `PoolableConnection(java.sql.Connection conn, ObjectPool<PoolableConnection> pool, AbandonedConfig config)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Returns me to my pool.
    `void` | `reallyClose()` Actually close my underlying `Connection`.

    - ### Methods inherited from class org.apache.tomcat.dbcp.dbcp.DelegatingConnection

      `abort, activate, checkOpen, clearWarnings, commit, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, equals, getAutoCommit, getCatalog, getClientInfo, getClientInfo, getDelegate, getDelegateInternal, getHoldability, getInnermostDelegate, getInnermostDelegateInternal, getMetaData, getNetworkTimeout, getSchema, getTransactionIsolation, getTypeMap, getWarnings, handleException, hashCode, innermostDelegateEquals, isClosed, isReadOnly, isValid, isWrapperFor, nativeSQL, passivate, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setClientInfo, setClientInfo, setDelegate, setHoldability, setNetworkTimeout, setReadOnly, setSavepoint, setSavepoint, setSchema, setTransactionIsolation, setTypeMap, toString, unwrap`

    - ### Methods inherited from class org.apache.tomcat.dbcp.dbcp.AbandonedTrace

      `addTrace, clearTrace, getConfig, getLastUsed, getTrace, printStackTrace, removeTrace, setLastUsed, setLastUsed, setStackTrace`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### _pool

          protected ObjectPool<PoolableConnection> _pool

      The pool to which I should return.

  - ### Constructor Detail

    - #### PoolableConnection

          public PoolableConnection(java.sql.Connection conn,
                            ObjectPool<PoolableConnection> pool)

      Parameters:
        `conn` - my underlying connection
        `pool` - the pool to which I should return when closed

    - #### PoolableConnection

          public PoolableConnection(java.sql.Connection conn,
                            ObjectPool<PoolableConnection> pool,
                            AbandonedConfig config)

      Parameters:
        `conn` - my underlying connection
        `pool` - the pool to which I should return when closed
        `config` - the abandoned configuration settings

  - ### Method Detail

    - #### close

          public void close()
                     throws java.sql.SQLException

      Returns me to my pool.
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Specified by:
        `close` in interface `java.sql.Connection`
      Overrides:
        `close` in class `DelegatingConnection`
      Throws:
        `java.sql.SQLException`

    - #### reallyClose

          public void reallyClose()
                           throws java.sql.SQLException

      Actually close my underlying `Connection`.
      Throws:
        `java.sql.SQLException`

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.