PoolableConnectionFactory (Apache Tomcat 7.0.104 API Documentation)

org.apache.tomcat.dbcp.dbcp

## Class PoolableConnectionFactory

- java.lang.Object
- - org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory

- All Implemented Interfaces:
    PoolableObjectFactory<PoolableConnection>

      public class PoolableConnectionFactory
      extends Object
      implements PoolableObjectFactory<PoolableConnection>

  A `PoolableObjectFactory` that creates `PoolableConnection`s.
  Author:
    Rodney Waldhoff, Glenn L. Nielsen, James House, Dirk Verbeeck

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AbandonedConfig` | `_config` Configuration for removing abandoned connections.
    `protected Collection<String>` | `_connectionInitSqls`
    `protected ConnectionFactory` | `_connFactory`
    `protected boolean` | `_defaultAutoCommit`
    `protected String` | `_defaultCatalog`
    `protected Boolean` | `_defaultReadOnly`
    `protected int` | `_defaultTransactionIsolation`
    `protected ObjectPool<PoolableConnection>` | `_pool`
    `protected KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement>` | `_stmtPoolFactory`
    `protected String` | `_validationQuery`
    `protected int` | `_validationQueryTimeout`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, AbandonedConfig config)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, AbandonedConfig config)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, Collection<String> connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, Collection<String> connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, Collection<String> connectionInitSqls, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, int validationQueryTimeout, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, int validationQueryTimeout, Collection<String> connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, int validationQueryTimeout, Collection<String> connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, String validationQuery, int validationQueryTimeout, Collection<String> connectionInitSqls, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, String defaultCatalog, AbandonedConfig config)` Create a new `PoolableConnectionFactory`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `activateObject(PoolableConnection conn)` Reinitialize an instance to be returned by the pool.
    `void` | `destroyObject(PoolableConnection obj)` Destroys an instance no longer needed by the pool.
    `ObjectPool<PoolableConnection>` | `getPool()` Returns the `ObjectPool` in which `Connection`s are pooled.
    `protected void` | `initializeConnection(Connection conn)`
    `PoolableConnection` | `makeObject()` Creates an instance that can be served by the pool.
    `void` | `passivateObject(PoolableConnection conn)` Uninitialize an instance to be returned to the idle object pool.
    `void` | `setConnectionFactory(ConnectionFactory connFactory)` Sets the `ConnectionFactory` from which to obtain base `Connection`s.
    `void` | `setConnectionInitSql(Collection<String> connectionInitSqls)` Sets the SQL statements I use to initialize newly created `Connection`s.
    `void` | `setDefaultAutoCommit(boolean defaultAutoCommit)` Sets the default "auto commit" setting for borrowed `Connection`s
    `void` | `setDefaultCatalog(String defaultCatalog)` Sets the default "catalog" setting for borrowed `Connection`s
    `void` | `setDefaultReadOnly(boolean defaultReadOnly)` Sets the default "read only" setting for borrowed `Connection`s
    `void` | `setDefaultTransactionIsolation(int defaultTransactionIsolation)` Sets the default "Transaction Isolation" setting for borrowed `Connection`s
    `void` | `setPool(ObjectPool<PoolableConnection> pool)` Sets the `ObjectPool` in which to pool `Connection`s.
    `void` | `setStatementPoolFactory(KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory)` Sets the `KeyedObjectPoolFactory` I use to create `KeyedObjectPool`s for pooling `PreparedStatement`s.
    `void` | `setValidationQuery(String validationQuery)` Sets the query I use to `validate` `Connection`s.
    `void` | `setValidationQueryTimeout(int timeout)` Sets the validation query timeout, the amount of time, in seconds, that connection validation will wait for a response from the database when executing a validation query.
    `void` | `validateConnection(Connection conn)`
    `boolean` | `validateObject(PoolableConnection obj)` Ensures that the instance is safe to be returned by the pool.

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

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

- - ### Field Detail

    - #### _connFactory

          protected volatile ConnectionFactory _connFactory

    - #### _validationQuery

          protected volatile String _validationQuery

    - #### _validationQueryTimeout

          protected volatile int _validationQueryTimeout

    - #### _connectionInitSqls

          protected Collection<String> _connectionInitSqls

    - #### _pool

          protected volatile ObjectPool<PoolableConnection> _pool

    - #### _stmtPoolFactory

          protected volatile KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> _stmtPoolFactory

    - #### _defaultReadOnly

          protected Boolean _defaultReadOnly

    - #### _defaultAutoCommit

          protected boolean _defaultAutoCommit

    - #### _defaultTransactionIsolation

          protected int _defaultTransactionIsolation

    - #### _defaultCatalog

          protected String _defaultCatalog

    - #### _config

          protected AbandonedConfig _config

      Configuration for removing abandoned connections.

  - ### Constructor Detail

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   boolean defaultReadOnly,
                                   boolean defaultAutoCommit)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   Collection<String> connectionInitSqls,
                                   boolean defaultReadOnly,
                                   boolean defaultAutoCommit)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `connectionInitSqls` - a Collection of SQL statements to initialize `Connection`s. Using `null` turns off initialization.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
      Since:
        1.3

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   int validationQueryTimeout,
                                   boolean defaultReadOnly,
                                   boolean defaultAutoCommit)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `validationQueryTimeout` - the number of seconds that validation queries will wait for database response before failing. Use a value less than or equal to 0 for no timeout.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
      Since:
        1.3

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   int validationQueryTimeout,
                                   Collection<String> connectionInitSqls,
                                   boolean defaultReadOnly,
                                   boolean defaultAutoCommit)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `validationQueryTimeout` - the number of seconds that validation queries will wait for database response before failing. Use a value less than or equal to 0 for no timeout.
        `connectionInitSqls` - a Collection of SQL statements to initialize `Connection`s. Using `null` turns off initialization.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
      Since:
        1.3

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
        `defaultTransactionIsolation` - the default "Transaction Isolation" setting for returned `Connection`s

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   Collection<String> connectionInitSqls,
                                   boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `connectionInitSqls` - a Collection of SQL statement to initialize `Connection`s. Using `null` turns off initialization.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
        `defaultTransactionIsolation` - the default "Transaction Isolation" setting for returned `Connection`s
      Since:
        1.3

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   int validationQueryTimeout,
                                   boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `validationQueryTimeout` - the number of seconds that validation queries will wait for database response before failing. Use a value less than or equal to 0 for no timeout.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
        `defaultTransactionIsolation` - the default "Transaction Isolation" setting for returned `Connection`s
      Since:
        1.3

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   int validationQueryTimeout,
                                   Collection<String> connectionInitSqls,
                                   boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `validationQueryTimeout` - the number of seconds that validation queries will wait for database response before failing. Use a value less than or equal to 0 for no timeout.
        `connectionInitSqls` - a Collection of SQL statement to initialize `Connection`s. Using `null` turns off initialization.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
        `defaultTransactionIsolation` - the default "Transaction Isolation" setting for returned `Connection`s
      Since:
        1.3

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   AbandonedConfig config)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
        `config` - the AbandonedConfig if tracing SQL objects

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation,
                                   AbandonedConfig config)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
        `defaultTransactionIsolation` - the default "Transaction Isolation" setting for returned `Connection`s
        `config` - the AbandonedConfig if tracing SQL objects

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation,
                                   String defaultCatalog,
                                   AbandonedConfig config)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
        `defaultTransactionIsolation` - the default "Transaction Isolation" setting for returned `Connection`s
        `defaultCatalog` - the default "catalog" setting for returned `Connection`s
        `config` - the AbandonedConfig if tracing SQL objects

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   Boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation,
                                   String defaultCatalog,
                                   AbandonedConfig config)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
        `defaultTransactionIsolation` - the default "Transaction Isolation" setting for returned `Connection`s
        `defaultCatalog` - the default "catalog" setting for returned `Connection`s
        `config` - the AbandonedConfig if tracing SQL objects

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   Collection<String> connectionInitSqls,
                                   Boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation,
                                   String defaultCatalog,
                                   AbandonedConfig config)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `connectionInitSqls` - a Collection of SQL statements to initialize `Connection`s. Using `null` turns off initialization.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
        `defaultTransactionIsolation` - the default "Transaction Isolation" setting for returned `Connection`s
        `defaultCatalog` - the default "catalog" setting for returned `Connection`s
        `config` - the AbandonedConfig if tracing SQL objects
      Since:
        1.3

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   int validationQueryTimeout,
                                   Boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation,
                                   String defaultCatalog,
                                   AbandonedConfig config)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `validationQueryTimeout` - the number of seconds that validation queries will wait for database response before failing. Use a value less than or equal to 0 for no timeout.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
        `defaultTransactionIsolation` - the default "Transaction Isolation" setting for returned `Connection`s
        `defaultCatalog` - the default "catalog" setting for returned `Connection`s
        `config` - the AbandonedConfig if tracing SQL objects
      Since:
        1.3

    - #### PoolableConnectionFactory

          public PoolableConnectionFactory(ConnectionFactory connFactory,
                                   ObjectPool<PoolableConnection> pool,
                                   KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory,
                                   String validationQuery,
                                   int validationQueryTimeout,
                                   Collection<String> connectionInitSqls,
                                   Boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation,
                                   String defaultCatalog,
                                   AbandonedConfig config)

      Create a new `PoolableConnectionFactory`.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s
        `pool` - the `ObjectPool` in which to pool those `Connection`s
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s, or `null` to disable `PreparedStatement` pooling
        `validationQuery` - a query to use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
        `validationQueryTimeout` - the number of seconds that validation queries will wait for database response before failing. Use a value less than or equal to 0 for no timeout.
        `connectionInitSqls` - a Collection of SQL statements to initialize `Connection`s. Using `null` turns off initialization.
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s
        `defaultAutoCommit` - the default "auto commit" setting for returned `Connection`s
        `defaultTransactionIsolation` - the default "Transaction Isolation" setting for returned `Connection`s
        `defaultCatalog` - the default "catalog" setting for returned `Connection`s
        `config` - the AbandonedConfig if tracing SQL objects
      Since:
        1.3

  - ### Method Detail

    - #### setConnectionFactory

          public void setConnectionFactory(ConnectionFactory connFactory)

      Sets the `ConnectionFactory` from which to obtain base `Connection`s.
      Parameters:
        `connFactory` - the `ConnectionFactory` from which to obtain base `Connection`s

    - #### setValidationQuery

          public void setValidationQuery(String validationQuery)

      Sets the query I use to `validate` `Connection`s. Should return at least one row. Using `null` turns off validation.
      Parameters:
        `validationQuery` - a query to use to `validate` `Connection`s.

    - #### setValidationQueryTimeout

          public void setValidationQueryTimeout(int timeout)

      Sets the validation query timeout, the amount of time, in seconds, that connection validation will wait for a response from the database when executing a validation query. Use a value less than or equal to 0 for no timeout.
      Parameters:
        `timeout` - new validation query timeout value in seconds
      Since:
        1.3

    - #### setConnectionInitSql

          public void setConnectionInitSql(Collection<String> connectionInitSqls)

      Sets the SQL statements I use to initialize newly created `Connection`s. Using `null` turns off connection initialization.
      Parameters:
        `connectionInitSqls` - SQL statement to initialize `Connection`s.
      Since:
        1.3

    - #### setPool

          public void setPool(ObjectPool<PoolableConnection> pool)

      Sets the `ObjectPool` in which to pool `Connection`s.
      Parameters:
        `pool` - the `ObjectPool` in which to pool those `Connection`s

    - #### getPool

          public ObjectPool<PoolableConnection> getPool()

      Returns the `ObjectPool` in which `Connection`s are pooled.
      Returns:
        the connection pool

    - #### setStatementPoolFactory

          public void setStatementPoolFactory(KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory)

      Sets the `KeyedObjectPoolFactory` I use to create `KeyedObjectPool`s for pooling `PreparedStatement`s. Set to `null` to disable `PreparedStatement` pooling.
      Parameters:
        `stmtPoolFactory` - the `KeyedObjectPoolFactory` to use to create `KeyedObjectPool`s for pooling `PreparedStatement`s

    - #### setDefaultReadOnly

          public void setDefaultReadOnly(boolean defaultReadOnly)

      Sets the default "read only" setting for borrowed `Connection`s
      Parameters:
        `defaultReadOnly` - the default "read only" setting for borrowed `Connection`s

    - #### setDefaultAutoCommit

          public void setDefaultAutoCommit(boolean defaultAutoCommit)

      Sets the default "auto commit" setting for borrowed `Connection`s
      Parameters:
        `defaultAutoCommit` - the default "auto commit" setting for borrowed `Connection`s

    - #### setDefaultTransactionIsolation

          public void setDefaultTransactionIsolation(int defaultTransactionIsolation)

      Sets the default "Transaction Isolation" setting for borrowed `Connection`s
      Parameters:
        `defaultTransactionIsolation` - the default "Transaction Isolation" setting for returned `Connection`s

    - #### setDefaultCatalog

          public void setDefaultCatalog(String defaultCatalog)

      Sets the default "catalog" setting for borrowed `Connection`s
      Parameters:
        `defaultCatalog` - the default "catalog" setting for borrowed `Connection`s

    - #### makeObject

          public PoolableConnection makeObject()
                                        throws Exception

      Description copied from interface: `PoolableObjectFactory`
      Creates an instance that can be served by the pool. Instances returned from this method should be in the same state as if they had been `activated`. They will not be activated before being served by the pool.
      Specified by:
        `makeObject` in interface `PoolableObjectFactory<PoolableConnection>`
      Returns:
        an instance that can be served by the pool.
      Throws:
        `Exception` - if there is a problem creating a new instance, this will be propagated to the code requesting an object.

    - #### initializeConnection

          protected void initializeConnection(Connection conn)
                                       throws SQLException

      Throws:
        `SQLException`

    - #### destroyObject

          public void destroyObject(PoolableConnection obj)
                             throws Exception

      Description copied from interface: `PoolableObjectFactory`
      Destroys an instance no longer needed by the pool.

      It is important for implementations of this method to be aware that there is no guarantee about what state `obj` will be in and the implementation should be prepared to handle unexpected errors.

      Also, an implementation must take in to consideration that instances lost to the garbage collector may never be destroyed.

      Specified by:
        `destroyObject` in interface `PoolableObjectFactory<PoolableConnection>`
      Parameters:
        `obj` - the instance to be destroyed
      Throws:
        `Exception` - should be avoided as it may be swallowed by the pool implementation.
      See Also:
        `PoolableObjectFactory.validateObject(T)`, `ObjectPool.invalidateObject(T)`

    - #### validateObject

          public boolean validateObject(PoolableConnection obj)

      Description copied from interface: `PoolableObjectFactory`
      Ensures that the instance is safe to be returned by the pool. Returns `false` if `obj` should be destroyed.
      Specified by:
        `validateObject` in interface `PoolableObjectFactory<PoolableConnection>`
      Parameters:
        `obj` - the instance to be validated
      Returns:
        `false` if `obj` is not valid and should be dropped from the pool, `true` otherwise.

    - #### validateConnection

          public void validateConnection(Connection conn)
                                  throws SQLException

      Throws:
        `SQLException`

    - #### passivateObject

          public void passivateObject(PoolableConnection conn)
                               throws Exception

      Description copied from interface: `PoolableObjectFactory`
      Uninitialize an instance to be returned to the idle object pool.
      Specified by:
        `passivateObject` in interface `PoolableObjectFactory<PoolableConnection>`
      Parameters:
        `conn` - the instance to be passivated
      Throws:
        `Exception` - if there is a problem passivating `obj`, this exception may be swallowed by the pool.
      See Also:
        `PoolableObjectFactory.destroyObject(T)`

    - #### activateObject

          public void activateObject(PoolableConnection conn)
                              throws Exception

      Description copied from interface: `PoolableObjectFactory`
      Reinitialize an instance to be returned by the pool.
      Specified by:
        `activateObject` in interface `PoolableObjectFactory<PoolableConnection>`
      Parameters:
        `conn` - the instance to be activated
      Throws:
        `Exception` - if there is a problem activating `obj`, this exception may be swallowed by the pool.
      See Also:
        `PoolableObjectFactory.destroyObject(T)`

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