InstanceKeyDataSource (Apache Tomcat 8.5.12 API Documentation)

org.apache.tomcat.dbcp.dbcp2.datasources

## Class InstanceKeyDataSource

- java.lang.Object
- - org.apache.tomcat.dbcp.dbcp2.datasources.InstanceKeyDataSource

- All Implemented Interfaces:
    Serializable, AutoCloseable, Wrapper, Referenceable, CommonDataSource, DataSource
  Direct Known Subclasses:
    PerUserPoolDataSource, SharedPoolDataSource

      public abstract class InstanceKeyDataSource
      extends Object
      implements DataSource, Referenceable, Serializable, AutoCloseable

  The base class for `SharedPoolDataSource` and `PerUserPoolDataSource`. Many of the configuration properties are shared and defined here. This class is declared public in order to allow particular usage with commons-beanutils; do not make direct use of it outside of commons-dbcp2.

  A J2EE container will normally provide some method of initializing the `DataSource` whose attributes are presented as bean getters/setters and then deploying it via JNDI. It is then available to an application as a source of pooled logical connections to the database. The pool needs a source of physical connections. This source is in the form of a `ConnectionPoolDataSource` that can be specified via the `setDataSourceName(String)` used to lookup the source via JNDI.

  Although normally used within a JNDI environment, A DataSource can be instantiated and initialized as any bean. In this case the `ConnectionPoolDataSource` will likely be instantiated in a similar manner. This class allows the physical source of connections to be attached directly to this pool using the `setConnectionPoolDataSource(ConnectionPoolDataSource)` method.

  The dbcp package contains an adapter, `DriverAdapterCPDS`, that can be used to allow the use of `DataSource`'s based on this class with JDBC driver implementations that do not supply a `ConnectionPoolDataSource`, but still provide a `Driver` implementation.

  The package documentation contains an example using Apache Tomcat and JNDI and it also contains a non-JNDI example.

  Since:
    2.0
  Author:
    John D. McNally
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static int` | `UNKNOWN_TRANSACTIONISOLATION` Internal constant to indicate the level is not set.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InstanceKeyDataSource()` Default no-arg constructor for Serialization

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `assertInitializationAllowed()` Throws an IllegalStateException, if a PooledConnection has already been requested.
    `abstract void` | `close()` Close the connection pool being maintained by this datasource.
    `Connection` | `getConnection()` Attempt to establish a database connection.
    `Connection` | `getConnection(String username, String password)` Attempt to retrieve a database connection using `getPooledConnectionAndInfo(String, String)` with the provided username and password.
    `protected abstract org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionManager` | `getConnectionManager(org.apache.tomcat.dbcp.dbcp2.datasources.UserPassKey upkey)`
    `ConnectionPoolDataSource` | `getConnectionPoolDataSource()` Get the value of connectionPoolDataSource.
    `String` | `getDataSourceName()` Get the name of the ConnectionPoolDataSource which backs this pool.
    `boolean` | `getDefaultBlockWhenExhausted()`
    `String` | `getDefaultEvictionPolicyClassName()`
    `boolean` | `getDefaultLifo()`
    `int` | `getDefaultMaxIdle()`
    `int` | `getDefaultMaxTotal()`
    `long` | `getDefaultMaxWaitMillis()`
    `long` | `getDefaultMinEvictableIdleTimeMillis()`
    `int` | `getDefaultMinIdle()`
    `int` | `getDefaultNumTestsPerEvictionRun()`
    `long` | `getDefaultSoftMinEvictableIdleTimeMillis()`
    `boolean` | `getDefaultTestOnBorrow()`
    `boolean` | `getDefaultTestOnCreate()`
    `boolean` | `getDefaultTestOnReturn()`
    `boolean` | `getDefaultTestWhileIdle()`
    `long` | `getDefaultTimeBetweenEvictionRunsMillis()`
    `int` | `getDefaultTransactionIsolation()` Get the value of defaultTransactionIsolation, which defines the state of connections handed out from this pool.
    `String` | `getDescription()` Get the description.
    `protected String` | `getInstanceKey()`
    `String` | `getJndiEnvironment(String key)` Get the value of jndiEnvironment which is used when instantiating a jndi InitialContext.
    `int` | `getLoginTimeout()` Get the value of loginTimeout.
    `PrintWriter` | `getLogWriter()` Get the value of logWriter.
    `long` | `getMaxConnLifetimeMillis()`
    `Logger` | `getParentLogger()`
    `protected abstract org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionAndInfo` | `getPooledConnectionAndInfo(String username, String password)`
    `String` | `getValidationQuery()` The SQL query that will be used to validate connections from this pool before returning them to the caller.
    `int` | `getValidationQueryTimeout()`
    `Boolean` | `isDefaultAutoCommit()` Get the value of defaultAutoCommit, which defines the state of connections handed out from this pool.
    `Boolean` | `isDefaultReadOnly()` Get the value of defaultReadOnly, which defines the state of connections handed out from this pool.
    `boolean` | `isRollbackAfterValidation()` Whether a rollback will be issued after executing the SQL query that will be used to validate connections from this pool before returning them to the caller.
    `boolean` | `isWrapperFor(Class<?> iface)`
    `void` | `setConnectionPoolDataSource(ConnectionPoolDataSource v)` Set the backend ConnectionPoolDataSource.
    `void` | `setDataSourceName(String v)` Set the name of the ConnectionPoolDataSource which backs this pool.
    `void` | `setDefaultAutoCommit(Boolean v)` Set the value of defaultAutoCommit, which defines the state of connections handed out from this pool.
    `void` | `setDefaultBlockWhenExhausted(boolean blockWhenExhausted)` Sets the default value for `BaseObjectPoolConfig.getBlockWhenExhausted()` for each per user pool.
    `void` | `setDefaultEvictionPolicyClassName(String evictionPolicyClassName)` Sets the default value for `BaseObjectPoolConfig.getEvictionPolicyClassName()` for each per user pool.
    `void` | `setDefaultLifo(boolean lifo)` Sets the default value for `BaseObjectPoolConfig.getLifo()` for each per user pool.
    `void` | `setDefaultMaxIdle(int maxIdle)` Sets the default value for `GenericKeyedObjectPoolConfig.getMaxIdlePerKey()` for each per user pool.
    `void` | `setDefaultMaxTotal(int maxTotal)` Sets the default value for `GenericKeyedObjectPoolConfig.getMaxTotalPerKey()` for each per user pool.
    `void` | `setDefaultMaxWaitMillis(long maxWaitMillis)` Sets the default value for `BaseObjectPoolConfig.getMaxWaitMillis()` for each per user pool.
    `void` | `setDefaultMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)` Sets the default value for `BaseObjectPoolConfig.getMinEvictableIdleTimeMillis()` for each per user pool.
    `void` | `setDefaultMinIdle(int minIdle)` Sets the default value for `GenericKeyedObjectPoolConfig.getMinIdlePerKey()` for each per user pool.
    `void` | `setDefaultNumTestsPerEvictionRun(int numTestsPerEvictionRun)` Sets the default value for `BaseObjectPoolConfig.getNumTestsPerEvictionRun()` for each per user pool.
    `void` | `setDefaultReadOnly(Boolean v)` Set the value of defaultReadOnly, which defines the state of connections handed out from this pool.
    `void` | `setDefaultSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis)` Sets the default value for `GenericObjectPool#getSoftMinEvictableIdleTimeMillis()` for each per user pool.
    `void` | `setDefaultTestOnBorrow(boolean testOnBorrow)` Sets the default value for `GenericObjectPool#getTestOnBorrow()` for each per user pool.
    `void` | `setDefaultTestOnCreate(boolean testOnCreate)` Sets the default value for `GenericObjectPool#getTestOnCreate()` for each per user pool.
    `void` | `setDefaultTestOnReturn(boolean testOnReturn)` Sets the default value for `GenericObjectPool#getTestOnReturn()` for each per user pool.
    `void` | `setDefaultTestWhileIdle(boolean testWhileIdle)` Sets the default value for `GenericObjectPool#getTestWhileIdle()` for each per user pool.
    `void` | `setDefaultTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)` Sets the default value for `GenericObjectPool#getTimeBetweenEvictionRunsMillis ()` for each per user pool.
    `void` | `setDefaultTransactionIsolation(int v)` Set the value of defaultTransactionIsolation, which defines the state of connections handed out from this pool.
    `void` | `setDescription(String v)` Set the description.
    `void` | `setJndiEnvironment(String key, String value)` Sets the value of the given JNDI environment property to be used when instantiating a JNDI InitialContext.
    `void` | `setLoginTimeout(int v)` Set the value of loginTimeout.
    `void` | `setLogWriter(PrintWriter v)` Set the value of logWriter.
    `void` | `setMaxConnLifetimeMillis(long maxConnLifetimeMillis)` Sets the maximum permitted lifetime of a connection in milliseconds.
    `void` | `setRollbackAfterValidation(boolean rollbackAfterValidation)` Whether a rollback will be issued after executing the SQL query that will be used to validate connections from this pool before returning them to the caller.
    `protected abstract void` | `setupDefaults(Connection con, String username)`
    `void` | `setValidationQuery(String validationQuery)` The SQL query that will be used to validate connections from this pool before returning them to the caller.
    `void` | `setValidationQueryTimeout(int validationQueryTimeout)` Sets the timeout in seconds before the validation query fails.
    `protected ConnectionPoolDataSource` | `testCPDS(String username, String password)`
    `<T> T` | `unwrap(Class<T> iface)`

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

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

    - ### Methods inherited from interface javax.naming.Referenceable

      `getReference`

- - ### Field Detail

    - #### UNKNOWN_TRANSACTIONISOLATION

          protected static final int UNKNOWN_TRANSACTIONISOLATION

      Internal constant to indicate the level is not set.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### InstanceKeyDataSource

          public InstanceKeyDataSource()

      Default no-arg constructor for Serialization

  - ### Method Detail

    - #### assertInitializationAllowed

          protected void assertInitializationAllowed()
                                              throws IllegalStateException

      Throws an IllegalStateException, if a PooledConnection has already been requested.
      Throws:
        `IllegalStateException`

    - #### close

          public abstract void close()
                              throws Exception

      Close the connection pool being maintained by this datasource.
      Specified by:
        `close` in interface `AutoCloseable`
      Throws:
        `Exception`

    - #### getConnectionManager

          protected abstract org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionManager getConnectionManager(org.apache.tomcat.dbcp.dbcp2.datasources.UserPassKey upkey)

    - #### isWrapperFor

          public boolean isWrapperFor(Class<?> iface)
                               throws SQLException

      Specified by:
        `isWrapperFor` in interface `Wrapper`
      Throws:
        `SQLException`

    - #### unwrap

          public <T> T unwrap(Class<T> iface)
                   throws SQLException

      Specified by:
        `unwrap` in interface `Wrapper`
      Throws:
        `SQLException`

    - #### getParentLogger

          public Logger getParentLogger()
                                 throws SQLFeatureNotSupportedException

      Specified by:
        `getParentLogger` in interface `CommonDataSource`
      Throws:
        `SQLFeatureNotSupportedException`

    - #### getDefaultBlockWhenExhausted

          public boolean getDefaultBlockWhenExhausted()

      Returns:
        the default value for `BaseObjectPoolConfig.getBlockWhenExhausted()` for each per user pool.

    - #### setDefaultBlockWhenExhausted

          public void setDefaultBlockWhenExhausted(boolean blockWhenExhausted)

      Sets the default value for `BaseObjectPoolConfig.getBlockWhenExhausted()` for each per user pool.
      Parameters:
        `blockWhenExhausted` - The new value

    - #### getDefaultEvictionPolicyClassName

          public String getDefaultEvictionPolicyClassName()

      Returns:
        the default value for `BaseObjectPoolConfig.getEvictionPolicyClassName()` for each per user pool.

    - #### setDefaultEvictionPolicyClassName

          public void setDefaultEvictionPolicyClassName(String evictionPolicyClassName)

      Sets the default value for `BaseObjectPoolConfig.getEvictionPolicyClassName()` for each per user pool.
      Parameters:
        `evictionPolicyClassName` - The new value

    - #### getDefaultLifo

          public boolean getDefaultLifo()

      Returns:
        the default value for `BaseObjectPoolConfig.getLifo()` for each per user pool.

    - #### setDefaultLifo

          public void setDefaultLifo(boolean lifo)

      Sets the default value for `BaseObjectPoolConfig.getLifo()` for each per user pool.
      Parameters:
        `lifo` - The new value

    - #### getDefaultMaxIdle

          public int getDefaultMaxIdle()

      Returns:
        the default value for `GenericKeyedObjectPoolConfig.getMaxIdlePerKey()` for each per user pool.

    - #### setDefaultMaxIdle

          public void setDefaultMaxIdle(int maxIdle)

      Sets the default value for `GenericKeyedObjectPoolConfig.getMaxIdlePerKey()` for each per user pool.
      Parameters:
        `maxIdle` - The new value

    - #### getDefaultMaxTotal

          public int getDefaultMaxTotal()

      Returns:
        the default value for `GenericKeyedObjectPoolConfig.getMaxTotalPerKey()` for each per user pool.

    - #### setDefaultMaxTotal

          public void setDefaultMaxTotal(int maxTotal)

      Sets the default value for `GenericKeyedObjectPoolConfig.getMaxTotalPerKey()` for each per user pool.
      Parameters:
        `maxTotal` - The new value

    - #### getDefaultMaxWaitMillis

          public long getDefaultMaxWaitMillis()

      Returns:
        the default value for `BaseObjectPoolConfig.getMaxWaitMillis()` for each per user pool.

    - #### setDefaultMaxWaitMillis

          public void setDefaultMaxWaitMillis(long maxWaitMillis)

      Sets the default value for `BaseObjectPoolConfig.getMaxWaitMillis()` for each per user pool.
      Parameters:
        `maxWaitMillis` - The new value

    - #### getDefaultMinEvictableIdleTimeMillis

          public long getDefaultMinEvictableIdleTimeMillis()

      Returns:
        the default value for `BaseObjectPoolConfig.getMinEvictableIdleTimeMillis()` for each per user pool.

    - #### setDefaultMinEvictableIdleTimeMillis

          public void setDefaultMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)

      Sets the default value for `BaseObjectPoolConfig.getMinEvictableIdleTimeMillis()` for each per user pool.
      Parameters:
        `minEvictableIdleTimeMillis` - The new value

    - #### getDefaultMinIdle

          public int getDefaultMinIdle()

      Returns:
        the default value for `GenericKeyedObjectPoolConfig.getMinIdlePerKey()` for each per user pool.

    - #### setDefaultMinIdle

          public void setDefaultMinIdle(int minIdle)

      Sets the default value for `GenericKeyedObjectPoolConfig.getMinIdlePerKey()` for each per user pool.
      Parameters:
        `minIdle` - The new value

    - #### getDefaultNumTestsPerEvictionRun

          public int getDefaultNumTestsPerEvictionRun()

      Returns:
        the default value for `BaseObjectPoolConfig.getNumTestsPerEvictionRun()` for each per user pool.

    - #### setDefaultNumTestsPerEvictionRun

          public void setDefaultNumTestsPerEvictionRun(int numTestsPerEvictionRun)

      Sets the default value for `BaseObjectPoolConfig.getNumTestsPerEvictionRun()` for each per user pool.
      Parameters:
        `numTestsPerEvictionRun` - The new value

    - #### getDefaultSoftMinEvictableIdleTimeMillis

          public long getDefaultSoftMinEvictableIdleTimeMillis()

      Returns:
        the default value for `GenericObjectPool#getSoftMinEvictableIdleTimeMillis()` for each per user pool.

    - #### setDefaultSoftMinEvictableIdleTimeMillis

          public void setDefaultSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis)

      Sets the default value for `GenericObjectPool#getSoftMinEvictableIdleTimeMillis()` for each per user pool.
      Parameters:
        `softMinEvictableIdleTimeMillis` - The new value

    - #### getDefaultTestOnCreate

          public boolean getDefaultTestOnCreate()

      Returns:
        the default value for `GenericObjectPool#getTestOnCreate()` for each per user pool.

    - #### setDefaultTestOnCreate

          public void setDefaultTestOnCreate(boolean testOnCreate)

      Sets the default value for `GenericObjectPool#getTestOnCreate()` for each per user pool.
      Parameters:
        `testOnCreate` - The new value

    - #### getDefaultTestOnBorrow

          public boolean getDefaultTestOnBorrow()

      Returns:
        the default value for `GenericObjectPool#getTestOnBorrow()` for each per user pool.

    - #### setDefaultTestOnBorrow

          public void setDefaultTestOnBorrow(boolean testOnBorrow)

      Sets the default value for `GenericObjectPool#getTestOnBorrow()` for each per user pool.
      Parameters:
        `testOnBorrow` - The new value

    - #### getDefaultTestOnReturn

          public boolean getDefaultTestOnReturn()

      Returns:
        the default value for `GenericObjectPool#getTestOnReturn()` for each per user pool.

    - #### setDefaultTestOnReturn

          public void setDefaultTestOnReturn(boolean testOnReturn)

      Sets the default value for `GenericObjectPool#getTestOnReturn()` for each per user pool.
      Parameters:
        `testOnReturn` - The new value

    - #### getDefaultTestWhileIdle

          public boolean getDefaultTestWhileIdle()

      Returns:
        the default value for `GenericObjectPool#getTestWhileIdle()` for each per user pool.

    - #### setDefaultTestWhileIdle

          public void setDefaultTestWhileIdle(boolean testWhileIdle)

      Sets the default value for `GenericObjectPool#getTestWhileIdle()` for each per user pool.
      Parameters:
        `testWhileIdle` - The new value

    - #### getDefaultTimeBetweenEvictionRunsMillis

          public long getDefaultTimeBetweenEvictionRunsMillis()

      Returns:
        the default value for `GenericObjectPool#getTimeBetweenEvictionRunsMillis ()` for each per user pool.

    - #### setDefaultTimeBetweenEvictionRunsMillis

          public void setDefaultTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)

      Sets the default value for `GenericObjectPool#getTimeBetweenEvictionRunsMillis ()` for each per user pool.
      Parameters:
        `timeBetweenEvictionRunsMillis` - The new value

    - #### getConnectionPoolDataSource

          public ConnectionPoolDataSource getConnectionPoolDataSource()

      Get the value of connectionPoolDataSource. This method will return null, if the backing datasource is being accessed via jndi.
      Returns:
        value of connectionPoolDataSource.

    - #### setConnectionPoolDataSource

          public void setConnectionPoolDataSource(ConnectionPoolDataSource v)

      Set the backend ConnectionPoolDataSource. This property should not be set if using jndi to access the datasource.
      Parameters:
        `v` - Value to assign to connectionPoolDataSource.

    - #### getDataSourceName

          public String getDataSourceName()

      Get the name of the ConnectionPoolDataSource which backs this pool. This name is used to look up the datasource from a jndi service provider.
      Returns:
        value of dataSourceName.

    - #### setDataSourceName

          public void setDataSourceName(String v)

      Set the name of the ConnectionPoolDataSource which backs this pool. This name is used to look up the datasource from a jndi service provider.
      Parameters:
        `v` - Value to assign to dataSourceName.

    - #### isDefaultAutoCommit

          public Boolean isDefaultAutoCommit()

      Get the value of defaultAutoCommit, which defines the state of connections handed out from this pool. The value can be changed on the Connection using Connection.setAutoCommit(boolean). The default is `null` which will use the default value for the drive.
      Returns:
        value of defaultAutoCommit.

    - #### setDefaultAutoCommit

          public void setDefaultAutoCommit(Boolean v)

      Set the value of defaultAutoCommit, which defines the state of connections handed out from this pool. The value can be changed on the Connection using Connection.setAutoCommit(boolean). The default is `null` which will use the default value for the drive.
      Parameters:
        `v` - Value to assign to defaultAutoCommit.

    - #### isDefaultReadOnly

          public Boolean isDefaultReadOnly()

      Get the value of defaultReadOnly, which defines the state of connections handed out from this pool. The value can be changed on the Connection using Connection.setReadOnly(boolean). The default is `null` which will use the default value for the drive.
      Returns:
        value of defaultReadOnly.

    - #### setDefaultReadOnly

          public void setDefaultReadOnly(Boolean v)

      Set the value of defaultReadOnly, which defines the state of connections handed out from this pool. The value can be changed on the Connection using Connection.setReadOnly(boolean). The default is `null` which will use the default value for the drive.
      Parameters:
        `v` - Value to assign to defaultReadOnly.

    - #### getDefaultTransactionIsolation

          public int getDefaultTransactionIsolation()

      Get the value of defaultTransactionIsolation, which defines the state of connections handed out from this pool. The value can be changed on the Connection using Connection.setTransactionIsolation(int). If this method returns -1, the default is JDBC driver dependent.
      Returns:
        value of defaultTransactionIsolation.

    - #### setDefaultTransactionIsolation

          public void setDefaultTransactionIsolation(int v)

      Set the value of defaultTransactionIsolation, which defines the state of connections handed out from this pool. The value can be changed on the Connection using Connection.setTransactionIsolation(int). The default is JDBC driver dependent.
      Parameters:
        `v` - Value to assign to defaultTransactionIsolation

    - #### getDescription

          public String getDescription()

      Get the description. This property is defined by JDBC as for use with GUI (or other) tools that might deploy the datasource. It serves no internal purpose.
      Returns:
        value of description.

    - #### setDescription

          public void setDescription(String v)

      Set the description. This property is defined by JDBC as for use with GUI (or other) tools that might deploy the datasource. It serves no internal purpose.
      Parameters:
        `v` - Value to assign to description.

    - #### getInstanceKey

          protected String getInstanceKey()

    - #### getJndiEnvironment

          public String getJndiEnvironment(String key)

      Get the value of jndiEnvironment which is used when instantiating a jndi InitialContext. This InitialContext is used to locate the backend ConnectionPoolDataSource.
      Parameters:
        `key` - The environment property name
      Returns:
        value of jndiEnvironment.

    - #### setJndiEnvironment

          public void setJndiEnvironment(String key,
                                String value)

      Sets the value of the given JNDI environment property to be used when instantiating a JNDI InitialContext. This InitialContext is used to locate the backend ConnectionPoolDataSource.
      Parameters:
        `key` - the JNDI environment property to set.
        `value` - the value assigned to specified JNDI environment property.

    - #### getLoginTimeout

          public int getLoginTimeout()

      Get the value of loginTimeout.
      Specified by:
        `getLoginTimeout` in interface `CommonDataSource`
      Returns:
        value of loginTimeout.

    - #### setLoginTimeout

          public void setLoginTimeout(int v)

      Set the value of loginTimeout.
      Specified by:
        `setLoginTimeout` in interface `CommonDataSource`
      Parameters:
        `v` - Value to assign to loginTimeout.

    - #### getLogWriter

          public PrintWriter getLogWriter()

      Get the value of logWriter.
      Specified by:
        `getLogWriter` in interface `CommonDataSource`
      Returns:
        value of logWriter.

    - #### setLogWriter

          public void setLogWriter(PrintWriter v)

      Set the value of logWriter.
      Specified by:
        `setLogWriter` in interface `CommonDataSource`
      Parameters:
        `v` - Value to assign to logWriter.

    - #### getValidationQuery

          public String getValidationQuery()

      The SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query MUST be an SQL SELECT statement that returns at least one row. If not specified, `Connection.isValid(int)` will be used to validate connections.
      Returns:
        the validation query

    - #### setValidationQuery

          public void setValidationQuery(String validationQuery)

      The SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query MUST be an SQL SELECT statement that returns at least one row. If not specified, connections will be validated using `Connection.isValid(int)`.
      Parameters:
        `validationQuery` - The validation query

    - #### getValidationQueryTimeout

          public int getValidationQueryTimeout()

      Returns:
        the timeout in seconds before the validation query fails.

    - #### setValidationQueryTimeout

          public void setValidationQueryTimeout(int validationQueryTimeout)

      Sets the timeout in seconds before the validation query fails.
      Parameters:
        `validationQueryTimeout` - The new timeout in seconds

    - #### isRollbackAfterValidation

          public boolean isRollbackAfterValidation()

      Whether a rollback will be issued after executing the SQL query that will be used to validate connections from this pool before returning them to the caller.
      Returns:
        true if a rollback will be issued after executing the validation query

    - #### setRollbackAfterValidation

          public void setRollbackAfterValidation(boolean rollbackAfterValidation)

      Whether a rollback will be issued after executing the SQL query that will be used to validate connections from this pool before returning them to the caller. Default behavior is NOT to issue a rollback. The setting will only have an effect if a validation query is set
      Parameters:
        `rollbackAfterValidation` - new property value

    - #### getMaxConnLifetimeMillis

          public long getMaxConnLifetimeMillis()

      Returns:
        the maximum permitted lifetime of a connection in milliseconds. A value of zero or less indicates an infinite lifetime.

    - #### setMaxConnLifetimeMillis

          public void setMaxConnLifetimeMillis(long maxConnLifetimeMillis)

      Sets the maximum permitted lifetime of a connection in milliseconds. A value of zero or less indicates an infinite lifetime.

      Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first time one of the following methods is invoked: `getConnection, setLogwriter, setLoginTimeout, getLoginTimeout, getLogWriter.`

      Parameters:
        `maxConnLifetimeMillis` - The maximum connection lifetime

    - #### getConnection

          public Connection getConnection()
                                   throws SQLException

      Attempt to establish a database connection.
      Specified by:
        `getConnection` in interface `DataSource`
      Returns:
        the connection
      Throws:
        `SQLException` - Connection failed

    - #### getConnection

          public Connection getConnection(String username,
                                 String password)
                                   throws SQLException

      Attempt to retrieve a database connection using `getPooledConnectionAndInfo(String, String)` with the provided username and password. The password on the `PooledConnectionAndInfo` instance returned by `getPooledConnectionAndInfo` is compared to the `password` parameter. If the comparison fails, a database connection using the supplied username and password is attempted. If the connection attempt fails, an SQLException is thrown, indicating that the given password did not match the password used to create the pooled connection. If the connection attempt succeeds, this means that the database password has been changed. In this case, the `PooledConnectionAndInfo` instance retrieved with the old password is destroyed and the `getPooledConnectionAndInfo` is repeatedly invoked until a `PooledConnectionAndInfo` instance with the new password is returned.
      Specified by:
        `getConnection` in interface `DataSource`
      Parameters:
        `username` - The user name to use to connect
        `password` - The password
      Returns:
        the connection
      Throws:
        `SQLException` - Connection failed

    - #### getPooledConnectionAndInfo

          protected abstract org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionAndInfo getPooledConnectionAndInfo(String username,
                                                                                                    String password)
                                                                                                                  throws SQLException

      Throws:
        `SQLException`

    - #### setupDefaults

          protected abstract void setupDefaults(Connection con,
                           String username)
                                         throws SQLException

      Throws:
        `SQLException`

    - #### testCPDS

          protected ConnectionPoolDataSource testCPDS(String username,
                                          String password)
                                               throws NamingException,
                                                      SQLException

      Throws:
        `NamingException`
        `SQLException`

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