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 java.lang.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 java.util.Collection<java.lang.String>` | `_connectionInitSqls`
    `protected ConnectionFactory` | `_connFactory`
    `protected boolean` | `_defaultAutoCommit`
    `protected java.lang.String` | `_defaultCatalog`
    `protected java.lang.Boolean` | `_defaultReadOnly`
    `protected int` | `_defaultTransactionIsolation`
    `protected ObjectPool<PoolableConnection>` | `_pool`
    `protected KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement>` | `_stmtPoolFactory`
    `protected java.lang.String` | `_validationQuery`
    `protected int` | `_validationQueryTimeout`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, AbandonedConfig config)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, AbandonedConfig config)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, java.lang.Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, java.util.Collection<java.lang.String> connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, java.util.Collection<java.lang.String> connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, java.util.Collection<java.lang.String> connectionInitSqls, java.lang.Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, java.lang.Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.String defaultCatalog, AbandonedConfig config)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, java.util.Collection<java.lang.String> connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, java.util.Collection<java.lang.String> connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation)` Create a new `PoolableConnectionFactory`.
    `PoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool<PoolableConnection> pool, KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> stmtPoolFactory, java.lang.String validationQuery, int validationQueryTimeout, java.util.Collection<java.lang.String> connectionInitSqls, java.lang.Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation, java.lang.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(java.sql.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(java.util.Collection<java.lang.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(java.lang.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(java.lang.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(java.sql.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 java.lang.String _validationQuery

    - #### _validationQueryTimeout

          protected volatile int _validationQueryTimeout

    - #### _connectionInitSqls

          protected java.util.Collection<java.lang.String> _connectionInitSqls

    - #### _pool

          protected volatile ObjectPool<PoolableConnection> _pool

    - #### _stmtPoolFactory

          protected volatile KeyedObjectPoolFactory<PStmtKey,DelegatingPreparedStatement> _stmtPoolFactory

    - #### _defaultReadOnly

          protected java.lang.Boolean _defaultReadOnly

    - #### _defaultAutoCommit

          protected boolean _defaultAutoCommit

    - #### _defaultTransactionIsolation

          protected int _defaultTransactionIsolation

    - #### _defaultCatalog

          protected java.lang.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,
                                   java.lang.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,
                                   java.lang.String validationQuery,
                                   java.util.Collection<java.lang.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,
                                   java.lang.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,
                                   java.lang.String validationQuery,
                                   int validationQueryTimeout,
                                   java.util.Collection<java.lang.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,
                                   java.lang.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,
                                   java.lang.String validationQuery,
                                   java.util.Collection<java.lang.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,
                                   java.lang.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,
                                   java.lang.String validationQuery,
                                   int validationQueryTimeout,
                                   java.util.Collection<java.lang.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,
                                   java.lang.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,
                                   java.lang.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,
                                   java.lang.String validationQuery,
                                   boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation,
                                   java.lang.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,
                                   java.lang.String validationQuery,
                                   java.lang.Boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation,
                                   java.lang.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,
                                   java.lang.String validationQuery,
                                   java.util.Collection<java.lang.String> connectionInitSqls,
                                   java.lang.Boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation,
                                   java.lang.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,
                                   java.lang.String validationQuery,
                                   int validationQueryTimeout,
                                   java.lang.Boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation,
                                   java.lang.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,
                                   java.lang.String validationQuery,
                                   int validationQueryTimeout,
                                   java.util.Collection<java.lang.String> connectionInitSqls,
                                   java.lang.Boolean defaultReadOnly,
                                   boolean defaultAutoCommit,
                                   int defaultTransactionIsolation,
                                   java.lang.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(java.lang.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(java.util.Collection<java.lang.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(java.lang.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 java.lang.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:
        `java.lang.Exception` - if there is a problem creating a new instance, this will be propagated to the code requesting an object.

    - #### initializeConnection

          protected void initializeConnection(java.sql.Connection conn)
                                       throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### destroyObject

          public void destroyObject(PoolableConnection obj)
                             throws java.lang.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:
        `java.lang.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(java.sql.Connection conn)
                                  throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### passivateObject

          public void passivateObject(PoolableConnection conn)
                               throws java.lang.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:
        `java.lang.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 java.lang.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:
        `java.lang.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.