Class PerUserPoolDataSource
- All Implemented Interfaces:
- Serializable,- AutoCloseable,- Wrapper,- Referenceable,- CommonDataSource,- DataSource
 A pooling DataSource appropriate for deployment within J2EE environment. There are many configuration
 options, most of which are defined in the parent class. This datasource uses individual pools per user, and some
 properties can be set specifically for a given user, if the deployment environment can support initialization of
 mapped properties. So for example, a pool of admin or write-access Connections can be guaranteed a certain number of
 connections, separate from a maximum set for users with read-only connections.
 
 User passwords can be changed without re-initializing the datasource. When a
 getConnection(userName, password) request is processed with a password that is different from those used
 to create connections in the pool associated with userName, an attempt is made to create a new
 connection using the supplied password and if this succeeds, the existing pool is cleared and a new pool is created
 for connections using the new password.
 
- Since:
- 2.0
- See Also:
- 
Field SummaryFields inherited from class org.apache.tomcat.dbcp.dbcp2.datasources.InstanceKeyDataSourceUNKNOWN_TRANSACTIONISOLATION
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()Clears pool(s) maintained by this data source.voidclose()Closes pool(s) maintained by this data source.protected org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionManagergetConnectionManager(org.apache.tomcat.dbcp.dbcp2.datasources.UserPassKey upKey) intGets the number of active connections in the default pool.intgetNumActive(String userName) Gets the number of active connections in the pool for a given user.intGets the number of idle connections in the default pool.intgetNumIdle(String userName) Gets the number of idle connections in the pool for a given user.booleangetPerUserBlockWhenExhausted(String userName) Gets the user specific value forBaseGenericObjectPool.getBlockWhenExhausted()for the specified user's pool or the default if no user specific value is defined.getPerUserDefaultAutoCommit(String userName) Gets the user specific default value forConnection.setAutoCommit(boolean)for the specified user's pool.getPerUserDefaultReadOnly(String userName) Gets the user specific default value forConnection.setReadOnly(boolean)for the specified user's pool.getPerUserDefaultTransactionIsolation(String userName) Gets the user specific default value forConnection.setTransactionIsolation(int)for the specified user's pool.getPerUserDurationBetweenEvictionRuns(String userName) Gets the user specific value forBaseGenericObjectPool.getDurationBetweenEvictionRuns()for the specified user's pool or the default if no user specific value is defined.getPerUserEvictionPolicyClassName(String userName) Gets the user specific value forBaseGenericObjectPool.getEvictionPolicyClassName()for the specified user's pool or the default if no user specific value is defined.booleangetPerUserLifo(String userName) Gets the user specific value forBaseGenericObjectPool.getLifo()for the specified user's pool or the default if no user specific value is defined.intgetPerUserMaxIdle(String userName) Gets the user specific value forGenericObjectPool.getMaxIdle()for the specified user's pool or the default if no user specific value is defined.intgetPerUserMaxTotal(String userName) Gets the user specific value forBaseGenericObjectPool.getMaxTotal()for the specified user's pool or the default if no user specific value is defined.getPerUserMaxWaitDuration(String userName) Gets the user specific value forBaseGenericObjectPool.getMaxWaitDuration()for the specified user's pool or the default if no user specific value is defined.longgetPerUserMaxWaitMillis(String userName) Deprecated.getPerUserMinEvictableIdleDuration(String userName) Gets the user specific value forBaseGenericObjectPool.getMinEvictableIdleDuration()for the specified user's pool or the default if no user specific value is defined.longgetPerUserMinEvictableIdleTimeMillis(String userName) Deprecated.intgetPerUserMinIdle(String userName) Gets the user specific value forGenericObjectPool.getMinIdle()for the specified user's pool or the default if no user specific value is defined.intgetPerUserNumTestsPerEvictionRun(String userName) Gets the user specific value forBaseGenericObjectPool.getNumTestsPerEvictionRun()for the specified user's pool or the default if no user specific value is defined.getPerUserSoftMinEvictableIdleDuration(String userName) Gets the user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleDuration()for the specified user's pool or the default if no user specific value is defined.longDeprecated.booleangetPerUserTestOnBorrow(String userName) Gets the user specific value forBaseGenericObjectPool.getTestOnBorrow()for the specified user's pool or the default if no user specific value is defined.booleangetPerUserTestOnCreate(String userName) Gets the user specific value forBaseGenericObjectPool.getTestOnCreate()for the specified user's pool or the default if no user specific value is defined.booleangetPerUserTestOnReturn(String userName) Gets the user specific value forBaseGenericObjectPool.getTestOnReturn()for the specified user's pool or the default if no user specific value is defined.booleangetPerUserTestWhileIdle(String userName) Gets the user specific value forBaseGenericObjectPool.getTestWhileIdle()for the specified user's pool or the default if no user specific value is defined.longDeprecated.protected org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionAndInfogetPooledConnectionAndInfo(String userName, String password) This method is protected but can only be implemented in this package because PooledConnectionAndInfo is a package private type.Returns aPerUserPoolDataSourceReference.voidsetPerUserBlockWhenExhausted(String userName, Boolean value) Sets a user specific value forBaseGenericObjectPool.getBlockWhenExhausted()for the specified user's pool.voidsetPerUserDefaultAutoCommit(String userName, Boolean value) Sets a user specific default value forConnection.setAutoCommit(boolean)for the specified user's pool.voidsetPerUserDefaultReadOnly(String userName, Boolean value) Sets a user specific default value forConnection.setReadOnly(boolean)for the specified user's pool.voidsetPerUserDefaultTransactionIsolation(String userName, Integer value) Sets a user specific default value forConnection.setTransactionIsolation(int)for the specified user's pool.voidsetPerUserDurationBetweenEvictionRuns(String userName, Duration value) Sets a user specific value forBaseGenericObjectPool.getDurationBetweenEvictionRuns()for the specified user's pool.voidsetPerUserEvictionPolicyClassName(String userName, String value) Sets a user specific value forBaseGenericObjectPool.getEvictionPolicyClassName()for the specified user's pool.voidsetPerUserLifo(String userName, Boolean value) Sets a user specific value forBaseGenericObjectPool.getLifo()for the specified user's pool.voidsetPerUserMaxIdle(String userName, Integer value) Sets a user specific value forGenericObjectPool.getMaxIdle()for the specified user's pool.voidsetPerUserMaxTotal(String userName, Integer value) Sets a user specific value forBaseGenericObjectPool.getMaxTotal()for the specified user's pool.voidsetPerUserMaxWait(String userName, Duration value) Sets a user specific value forBaseGenericObjectPool.getMaxWaitDuration()for the specified user's pool.voidsetPerUserMaxWaitMillis(String userName, Long value) Deprecated.voidsetPerUserMinEvictableIdle(String userName, Duration value) Sets a user specific value forBaseGenericObjectPool.getMinEvictableIdleDuration()for the specified user's pool.voidsetPerUserMinEvictableIdleTimeMillis(String userName, Long value) Deprecated.voidsetPerUserMinIdle(String userName, Integer value) Sets a user specific value forGenericObjectPool.getMinIdle()for the specified user's pool.voidsetPerUserNumTestsPerEvictionRun(String userName, Integer value) Sets a user specific value forBaseGenericObjectPool.getNumTestsPerEvictionRun()for the specified user's pool.voidsetPerUserSoftMinEvictableIdle(String userName, Duration value) Sets a user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleDuration()for the specified user's pool.voidsetPerUserSoftMinEvictableIdleTimeMillis(String userName, Long value) Deprecated.voidsetPerUserTestOnBorrow(String userName, Boolean value) Sets a user specific value forBaseGenericObjectPool.getTestOnBorrow()for the specified user's pool.voidsetPerUserTestOnCreate(String userName, Boolean value) Sets a user specific value forBaseGenericObjectPool.getTestOnCreate()for the specified user's pool.voidsetPerUserTestOnReturn(String userName, Boolean value) Sets a user specific value forBaseGenericObjectPool.getTestOnReturn()for the specified user's pool.voidsetPerUserTestWhileIdle(String userName, Boolean value) Sets a user specific value forBaseGenericObjectPool.getTestWhileIdle()for the specified user's pool.voidsetPerUserTimeBetweenEvictionRunsMillis(String userName, Long value) Deprecated.protected voidsetupDefaults(Connection con, String userName) Methods inherited from class org.apache.tomcat.dbcp.dbcp2.datasources.InstanceKeyDataSourceassertInitializationAllowed, getConnection, getConnection, getConnectionPoolDataSource, getDataSourceName, getDefaultBlockWhenExhausted, getDefaultDurationBetweenEvictionRuns, getDefaultEvictionPolicyClassName, getDefaultLifo, getDefaultMaxIdle, getDefaultMaxTotal, getDefaultMaxWait, getDefaultMaxWaitMillis, getDefaultMinEvictableIdleDuration, getDefaultMinEvictableIdleTimeMillis, getDefaultMinIdle, getDefaultNumTestsPerEvictionRun, getDefaultSoftMinEvictableIdleDuration, getDefaultSoftMinEvictableIdleTimeMillis, getDefaultTestOnBorrow, getDefaultTestOnCreate, getDefaultTestOnReturn, getDefaultTestWhileIdle, getDefaultTimeBetweenEvictionRunsMillis, getDefaultTransactionIsolation, getDescription, getInstanceKey, getJndiEnvironment, getLoginTimeout, getLoginTimeoutDuration, getLogWriter, getMaxConnDuration, getMaxConnLifetime, getMaxConnLifetimeMillis, getParentLogger, getValidationQuery, getValidationQueryTimeout, getValidationQueryTimeoutDuration, isDefaultAutoCommit, isDefaultReadOnly, isRollbackAfterValidation, isWrapperFor, setConnectionPoolDataSource, setDataSourceName, setDefaultAutoCommit, setDefaultBlockWhenExhausted, setDefaultDurationBetweenEvictionRuns, setDefaultEvictionPolicyClassName, setDefaultLifo, setDefaultMaxIdle, setDefaultMaxTotal, setDefaultMaxWait, setDefaultMaxWaitMillis, setDefaultMinEvictableIdle, setDefaultMinEvictableIdleTimeMillis, setDefaultMinIdle, setDefaultNumTestsPerEvictionRun, setDefaultReadOnly, setDefaultSoftMinEvictableIdle, setDefaultSoftMinEvictableIdleTimeMillis, setDefaultTestOnBorrow, setDefaultTestOnCreate, setDefaultTestOnReturn, setDefaultTestWhileIdle, setDefaultTimeBetweenEvictionRunsMillis, setDefaultTransactionIsolation, setDescription, setJndiEnvironment, setLoginTimeout, setLoginTimeout, setLogWriter, setMaxConnLifetime, setMaxConnLifetimeMillis, setRollbackAfterValidation, setValidationQuery, setValidationQueryTimeout, setValidationQueryTimeout, testCPDS, toString, toStringFields, unwrapMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javax.sql.CommonDataSourcecreateShardingKeyBuilderMethods inherited from interface javax.sql.DataSourcecreateConnectionBuilder
- 
Constructor Details- 
PerUserPoolDataSourcepublic PerUserPoolDataSource()Default no-arg constructor for Serialization.
 
- 
- 
Method Details- 
clearpublic void clear()Clears pool(s) maintained by this data source.- Since:
- 2.3.0
- See Also:
 
- 
closepublic void close()Closes pool(s) maintained by this data source.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein class- InstanceKeyDataSource
- See Also:
 
- 
getConnectionManagerprotected org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionManager getConnectionManager(org.apache.tomcat.dbcp.dbcp2.datasources.UserPassKey upKey) - Specified by:
- getConnectionManagerin class- InstanceKeyDataSource
 
- 
getNumActivepublic int getNumActive()Gets the number of active connections in the default pool.- Returns:
- The number of active connections in the default pool.
 
- 
getNumActiveGets the number of active connections in the pool for a given user.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getNumIdlepublic int getNumIdle()Gets the number of idle connections in the default pool.- Returns:
- The number of idle connections in the default pool.
 
- 
getNumIdleGets the number of idle connections in the pool for a given user.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserBlockWhenExhaustedGets the user specific value forBaseGenericObjectPool.getBlockWhenExhausted()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserDefaultAutoCommitGets the user specific default value forConnection.setAutoCommit(boolean)for the specified user's pool.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserDefaultReadOnlyGets the user specific default value forConnection.setReadOnly(boolean)for the specified user's pool.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserDefaultTransactionIsolationGets the user specific default value forConnection.setTransactionIsolation(int)for the specified user's pool.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserDurationBetweenEvictionRunsGets the user specific value forBaseGenericObjectPool.getDurationBetweenEvictionRuns()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
- Since:
- 2.10.0
 
- 
getPerUserEvictionPolicyClassNameGets the user specific value forBaseGenericObjectPool.getEvictionPolicyClassName()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserLifoGets the user specific value forBaseGenericObjectPool.getLifo()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserMaxIdleGets the user specific value forGenericObjectPool.getMaxIdle()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserMaxTotalGets the user specific value forBaseGenericObjectPool.getMaxTotal()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserMaxWaitDurationGets the user specific value forBaseGenericObjectPool.getMaxWaitDuration()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
- Since:
- 2.10.0
 
- 
getPerUserMaxWaitMillisDeprecated.Gets the user specific value forBaseGenericObjectPool.getMaxWaitDuration()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserMinEvictableIdleDurationGets the user specific value forBaseGenericObjectPool.getMinEvictableIdleDuration()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value, never null.
- Since:
- 2.10.0
 
- 
getPerUserMinEvictableIdleTimeMillisDeprecated.Gets the user specific value forBaseGenericObjectPool.getMinEvictableIdleDuration()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserMinIdleGets the user specific value forGenericObjectPool.getMinIdle()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserNumTestsPerEvictionRunGets the user specific value forBaseGenericObjectPool.getNumTestsPerEvictionRun()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserSoftMinEvictableIdleDurationGets the user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleDuration()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
- Since:
- 2.10.0
 
- 
getPerUserSoftMinEvictableIdleTimeMillisDeprecated.Gets the user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleDuration()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserTestOnBorrowGets the user specific value forBaseGenericObjectPool.getTestOnBorrow()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserTestOnCreateGets the user specific value forBaseGenericObjectPool.getTestOnCreate()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserTestOnReturnGets the user specific value forBaseGenericObjectPool.getTestOnReturn()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserTestWhileIdleGets the user specific value forBaseGenericObjectPool.getTestWhileIdle()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPerUserTimeBetweenEvictionRunsMillisDeprecated.Gets the user specific value forBaseGenericObjectPool.getDurationBetweenEvictionRuns()for the specified user's pool or the default if no user specific value is defined.- Parameters:
- userName- The user name key.
- Returns:
- The user specific value.
 
- 
getPooledConnectionAndInfoprotected org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionAndInfo getPooledConnectionAndInfo(String userName, String password) throws SQLException Description copied from class:InstanceKeyDataSourceThis method is protected but can only be implemented in this package because PooledConnectionAndInfo is a package private type.- Specified by:
- getPooledConnectionAndInfoin class- InstanceKeyDataSource
- Parameters:
- userName- The user name.
- password- The user password.
- Returns:
- Matching PooledConnectionAndInfo.
- Throws:
- SQLException- Connection or registration failure.
 
- 
getReferenceReturns aPerUserPoolDataSourceReference.- Throws:
- NamingException
 
- 
setPerUserBlockWhenExhaustedSets a user specific value forBaseGenericObjectPool.getBlockWhenExhausted()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserDefaultAutoCommitSets a user specific default value forConnection.setAutoCommit(boolean)for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserDefaultReadOnlySets a user specific default value forConnection.setReadOnly(boolean)for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserDefaultTransactionIsolationSets a user specific default value forConnection.setTransactionIsolation(int)for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserDurationBetweenEvictionRunsSets a user specific value forBaseGenericObjectPool.getDurationBetweenEvictionRuns()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
- Since:
- 2.10.0
 
- 
setPerUserEvictionPolicyClassNameSets a user specific value forBaseGenericObjectPool.getEvictionPolicyClassName()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserLifoSets a user specific value forBaseGenericObjectPool.getLifo()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserMaxIdleSets a user specific value forGenericObjectPool.getMaxIdle()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserMaxTotalSets a user specific value forBaseGenericObjectPool.getMaxTotal()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserMaxWaitSets a user specific value forBaseGenericObjectPool.getMaxWaitDuration()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
- Since:
- 2.10.0
 
- 
setPerUserMaxWaitMillisDeprecated.Sets a user specific value forBaseGenericObjectPool.getMaxWaitDuration()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserMinEvictableIdleSets a user specific value forBaseGenericObjectPool.getMinEvictableIdleDuration()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
- Since:
- 2.10.0
 
- 
setPerUserMinEvictableIdleTimeMillisDeprecated.Sets a user specific value forBaseGenericObjectPool.getMinEvictableIdleDuration()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserMinIdleSets a user specific value forGenericObjectPool.getMinIdle()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserNumTestsPerEvictionRunSets a user specific value forBaseGenericObjectPool.getNumTestsPerEvictionRun()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserSoftMinEvictableIdleSets a user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleDuration()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
- Since:
- 2.10.0
 
- 
setPerUserSoftMinEvictableIdleTimeMillisDeprecated.Sets a user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleDuration()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserTestOnBorrowSets a user specific value forBaseGenericObjectPool.getTestOnBorrow()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserTestOnCreateSets a user specific value forBaseGenericObjectPool.getTestOnCreate()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserTestOnReturnSets a user specific value forBaseGenericObjectPool.getTestOnReturn()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserTestWhileIdleSets a user specific value forBaseGenericObjectPool.getTestWhileIdle()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setPerUserTimeBetweenEvictionRunsMillisDeprecated.Sets a user specific value forBaseGenericObjectPool.getDurationBetweenEvictionRuns()for the specified user's pool.- Parameters:
- userName- The user name key.
- value- The user specific value.
 
- 
setupDefaults- Specified by:
- setupDefaultsin class- InstanceKeyDataSource
- Throws:
- SQLException
 
 
- 
getPerUserMaxWaitDuration(java.lang.String).