public interface PooledDataSource
extends javax.sql.DataSource
Most clients need never use or know about this interface -- c3p0 pooled DataSources can be treated like any other DataSource.
The functionality in this interface will be only be of interest if 1) for administrative reasons you like to keep close track of the number and status of all Connections your application is using; 2) to work around problems encountered while managing a DataSource whose clients are poorly coded applications that leak Connections, but which you are not permitted to fix; or 3) to work around problems that may occur if an underlying jdbc driver / DBMS system is unreliable. In the third case, most users will be better off not using the present interface at all, and using the DataSources' maxIdleTime, idleConnectionTestPeriod, or testConnectionOnCheckout parameters to help your DataSources "automatically" heal. But for those who prefer a more direct, manual approach, this interface is for you. It is anticipated that the methods of this interface will primarily be of use to administrators managing c3p0 PooledDataSources via JMX MBeans.
To understand this interface, you need to realize that a c3p0 PooledDataSource may represent not just one pool of Connections, but many, if users call the method Connection getConnection(String username, String password) rather than the no-argument getConnection() method. If users make use of non-default username, password combinations, there will be a separate pool for each set of authentification criteria supplied.
Many methods in this interface have three variants:
The first variant makes use of the pool maintained for the default user -- Connections created by calls to the no argument getConnection(), the second variant lets you keeps track of pools created by calling getConnection( username, password ), and the third variant provides aggregate information or performs operation on all pools.
Under most circumstances, non-default authentication credentials will not be used, and methods of the first variant are sufficient to manage the DataSource.
A properly configured PooledDataSource whose applications are careful to close all checked-out Connections would never need to use these methods. But, sometimes applications are untrustworthy and leak Connections, or database administrators suspect that Connections may be corrupt or invalid, and would like to force a pool to flush and acquire fresh Connections. This interface provides two ways to do so.
For each per-user pool, four different statistics are available:
Modifier and Type | Method and Description |
---|---|
void |
close()
C3P0 pooled DataSources use no resources before they are actually used in a VM,
and they close themselves in their finalize() method.
|
void |
close(boolean force_destory)
Deprecated.
the force_destroy argument is now meaningless, as pools are no longer
potentially shared between multiple DataSources.
|
java.util.Collection |
getAllUsers() |
java.lang.String |
getDataSourceName() |
float |
getEffectivePropertyCycle(java.lang.String username,
java.lang.String password) |
float |
getEffectivePropertyCycleDefaultUser() |
java.util.Map |
getExtensions() |
java.lang.String |
getIdentityToken() |
java.lang.Throwable |
getLastAcquisitionFailure(java.lang.String username,
java.lang.String password) |
java.lang.Throwable |
getLastAcquisitionFailureDefaultUser() |
java.lang.Throwable |
getLastCheckinFailure(java.lang.String username,
java.lang.String password) |
java.lang.Throwable |
getLastCheckinFailureDefaultUser() |
java.lang.Throwable |
getLastCheckoutFailure(java.lang.String username,
java.lang.String password) |
java.lang.Throwable |
getLastCheckoutFailureDefaultUser() |
java.lang.Throwable |
getLastConnectionTestFailure(java.lang.String username,
java.lang.String password) |
java.lang.Throwable |
getLastConnectionTestFailureDefaultUser() |
java.lang.Throwable |
getLastIdleTestFailure(java.lang.String username,
java.lang.String password) |
java.lang.Throwable |
getLastIdleTestFailureDefaultUser() |
int |
getNumBusyConnections()
Deprecated.
use getNumBusyConnectionsDefaultUser()
|
int |
getNumBusyConnections(java.lang.String username,
java.lang.String password) |
int |
getNumBusyConnectionsAllUsers() |
int |
getNumBusyConnectionsDefaultUser() |
int |
getNumConnections()
Deprecated.
use getNumConnectionsDefaultUser()
|
int |
getNumConnections(java.lang.String username,
java.lang.String password) |
int |
getNumConnectionsAllUsers() |
int |
getNumConnectionsDefaultUser() |
long |
getNumFailedCheckinsDefaultUser() |
long |
getNumFailedCheckoutsDefaultUser() |
long |
getNumFailedIdleTestsDefaultUser() |
int |
getNumHelperThreads() |
int |
getNumIdleConnections()
Deprecated.
use getNumIdleConnectionsDefaultUser()
|
int |
getNumIdleConnections(java.lang.String username,
java.lang.String password) |
int |
getNumIdleConnectionsAllUsers() |
int |
getNumIdleConnectionsDefaultUser() |
int |
getNumThreadsAwaitingCheckout(java.lang.String username,
java.lang.String password) |
int |
getNumThreadsAwaitingCheckoutDefaultUser() |
int |
getNumUnclosedOrphanedConnections()
Deprecated.
use getNumUnclosedOrphanedConnectionsDefaultUser()
|
int |
getNumUnclosedOrphanedConnections(java.lang.String username,
java.lang.String password) |
int |
getNumUnclosedOrphanedConnectionsAllUsers() |
int |
getNumUnclosedOrphanedConnectionsDefaultUser() |
int |
getNumUserPools() |
long |
getStartTimeMillisDefaultUser() |
int |
getStatementCacheNumCheckedOut(java.lang.String username,
java.lang.String password) |
int |
getStatementCacheNumCheckedOutDefaultUser() |
int |
getStatementCacheNumCheckedOutStatementsAllUsers() |
int |
getStatementCacheNumConnectionsWithCachedStatements(java.lang.String username,
java.lang.String password) |
int |
getStatementCacheNumConnectionsWithCachedStatementsAllUsers() |
int |
getStatementCacheNumConnectionsWithCachedStatementsDefaultUser() |
int |
getStatementCacheNumStatements(java.lang.String username,
java.lang.String password) |
int |
getStatementCacheNumStatementsAllUsers() |
int |
getStatementCacheNumStatementsDefaultUser() |
int |
getStatementDestroyerNumActiveThreads() |
int |
getStatementDestroyerNumConnectionsInUse(java.lang.String username,
java.lang.String password) |
int |
getStatementDestroyerNumConnectionsInUseAllUsers() |
int |
getStatementDestroyerNumConnectionsInUseDefaultUser() |
int |
getStatementDestroyerNumConnectionsWithDeferredDestroyStatements(java.lang.String username,
java.lang.String password) |
int |
getStatementDestroyerNumConnectionsWithDeferredDestroyStatementsAllUsers() |
int |
getStatementDestroyerNumConnectionsWithDeferredDestroyStatementsDefaultUser() |
int |
getStatementDestroyerNumDeferredDestroyStatements(java.lang.String username,
java.lang.String password) |
int |
getStatementDestroyerNumDeferredDestroyStatementsAllUsers() |
int |
getStatementDestroyerNumDeferredDestroyStatementsDefaultUser() |
int |
getStatementDestroyerNumIdleThreads() |
int |
getStatementDestroyerNumTasksPending() |
int |
getStatementDestroyerNumThreads() |
int |
getThreadPoolNumActiveThreads() |
int |
getThreadPoolNumIdleThreads() |
int |
getThreadPoolNumTasksPending() |
int |
getThreadPoolSize() |
long |
getUpTimeMillisDefaultUser() |
void |
hardReset()
Destroys all pooled and checked-out Connections associated with
this DataSource immediately.
|
java.lang.String |
sampleLastAcquisitionFailureStackTrace(java.lang.String username,
java.lang.String password) |
java.lang.String |
sampleLastAcquisitionFailureStackTraceDefaultUser() |
java.lang.String |
sampleLastCheckinFailureStackTrace(java.lang.String username,
java.lang.String password) |
java.lang.String |
sampleLastCheckinFailureStackTraceDefaultUser() |
java.lang.String |
sampleLastCheckoutFailureStackTrace(java.lang.String username,
java.lang.String password) |
java.lang.String |
sampleLastCheckoutFailureStackTraceDefaultUser() |
java.lang.String |
sampleLastConnectionTestFailureStackTrace(java.lang.String username,
java.lang.String password) |
java.lang.String |
sampleLastConnectionTestFailureStackTraceDefaultUser() |
java.lang.String |
sampleLastIdleTestFailureStackTrace(java.lang.String username,
java.lang.String password) |
java.lang.String |
sampleLastIdleTestFailureStackTraceDefaultUser() |
java.lang.String |
sampleStatementCacheStatus(java.lang.String username,
java.lang.String password) |
java.lang.String |
sampleStatementCacheStatusDefaultUser() |
java.lang.String |
sampleStatementDestroyerStackTraces() |
java.lang.String |
sampleStatementDestroyerStatus() |
java.lang.String |
sampleThreadPoolStackTraces() |
java.lang.String |
sampleThreadPoolStatus() |
void |
setDataSourceName(java.lang.String dataSourceName) |
void |
setExtensions(java.util.Map extensions) |
void |
softReset(java.lang.String username,
java.lang.String password)
Discards all Connections managed by the PooledDataSource with the specified authentication credentials
and reacquires new Connections to populate.
|
void |
softResetAllUsers()
Discards all Connections managed by the PooledDataSource
and reacquires new Connections to populate.
|
void |
softResetDefaultUser()
Discards all Connections managed by the PooledDataSource's default-authentication pool
and reacquires new Connections to populate.
|
java.lang.String getIdentityToken()
java.lang.String getDataSourceName()
void setDataSourceName(java.lang.String dataSourceName)
java.util.Map getExtensions()
void setExtensions(java.util.Map extensions)
int getNumConnections() throws java.sql.SQLException
java.sql.SQLException
int getNumIdleConnections() throws java.sql.SQLException
java.sql.SQLException
int getNumBusyConnections() throws java.sql.SQLException
java.sql.SQLException
int getNumUnclosedOrphanedConnections() throws java.sql.SQLException
java.sql.SQLException
int getNumConnectionsDefaultUser() throws java.sql.SQLException
java.sql.SQLException
int getNumIdleConnectionsDefaultUser() throws java.sql.SQLException
java.sql.SQLException
int getNumBusyConnectionsDefaultUser() throws java.sql.SQLException
java.sql.SQLException
int getNumUnclosedOrphanedConnectionsDefaultUser() throws java.sql.SQLException
java.sql.SQLException
int getStatementCacheNumStatementsDefaultUser() throws java.sql.SQLException
java.sql.SQLException
int getStatementCacheNumCheckedOutDefaultUser() throws java.sql.SQLException
java.sql.SQLException
int getStatementCacheNumConnectionsWithCachedStatementsDefaultUser() throws java.sql.SQLException
java.sql.SQLException
long getStartTimeMillisDefaultUser() throws java.sql.SQLException
java.sql.SQLException
long getUpTimeMillisDefaultUser() throws java.sql.SQLException
java.sql.SQLException
long getNumFailedCheckinsDefaultUser() throws java.sql.SQLException
java.sql.SQLException
long getNumFailedCheckoutsDefaultUser() throws java.sql.SQLException
java.sql.SQLException
long getNumFailedIdleTestsDefaultUser() throws java.sql.SQLException
java.sql.SQLException
float getEffectivePropertyCycleDefaultUser() throws java.sql.SQLException
java.sql.SQLException
int getNumThreadsAwaitingCheckoutDefaultUser() throws java.sql.SQLException
java.sql.SQLException
void softResetDefaultUser() throws java.sql.SQLException
java.sql.SQLException
int getNumConnections(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
int getNumIdleConnections(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
int getNumBusyConnections(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
int getNumUnclosedOrphanedConnections(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
int getStatementCacheNumStatements(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
int getStatementCacheNumCheckedOut(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
int getStatementCacheNumConnectionsWithCachedStatements(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
float getEffectivePropertyCycle(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
int getNumThreadsAwaitingCheckout(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
void softReset(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
int getNumBusyConnectionsAllUsers() throws java.sql.SQLException
java.sql.SQLException
int getNumIdleConnectionsAllUsers() throws java.sql.SQLException
java.sql.SQLException
int getNumConnectionsAllUsers() throws java.sql.SQLException
java.sql.SQLException
int getNumUnclosedOrphanedConnectionsAllUsers() throws java.sql.SQLException
java.sql.SQLException
int getStatementCacheNumStatementsAllUsers() throws java.sql.SQLException
java.sql.SQLException
int getStatementCacheNumCheckedOutStatementsAllUsers() throws java.sql.SQLException
java.sql.SQLException
int getStatementCacheNumConnectionsWithCachedStatementsAllUsers() throws java.sql.SQLException
java.sql.SQLException
int getStatementDestroyerNumConnectionsInUseAllUsers() throws java.sql.SQLException
java.sql.SQLException
int getStatementDestroyerNumConnectionsWithDeferredDestroyStatementsAllUsers() throws java.sql.SQLException
java.sql.SQLException
int getStatementDestroyerNumDeferredDestroyStatementsAllUsers() throws java.sql.SQLException
java.sql.SQLException
int getThreadPoolSize() throws java.sql.SQLException
java.sql.SQLException
int getThreadPoolNumActiveThreads() throws java.sql.SQLException
java.sql.SQLException
int getThreadPoolNumIdleThreads() throws java.sql.SQLException
java.sql.SQLException
int getThreadPoolNumTasksPending() throws java.sql.SQLException
java.sql.SQLException
int getStatementDestroyerNumThreads() throws java.sql.SQLException
java.sql.SQLException
int getStatementDestroyerNumActiveThreads() throws java.sql.SQLException
java.sql.SQLException
int getStatementDestroyerNumIdleThreads() throws java.sql.SQLException
java.sql.SQLException
int getStatementDestroyerNumTasksPending() throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleThreadPoolStackTraces() throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleThreadPoolStatus() throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleStatementDestroyerStackTraces() throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleStatementDestroyerStatus() throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleStatementCacheStatusDefaultUser() throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleStatementCacheStatus(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
java.lang.Throwable getLastAcquisitionFailureDefaultUser() throws java.sql.SQLException
java.sql.SQLException
java.lang.Throwable getLastCheckinFailureDefaultUser() throws java.sql.SQLException
java.sql.SQLException
java.lang.Throwable getLastCheckoutFailureDefaultUser() throws java.sql.SQLException
java.sql.SQLException
java.lang.Throwable getLastIdleTestFailureDefaultUser() throws java.sql.SQLException
java.sql.SQLException
java.lang.Throwable getLastConnectionTestFailureDefaultUser() throws java.sql.SQLException
java.sql.SQLException
int getStatementDestroyerNumConnectionsInUseDefaultUser() throws java.sql.SQLException
java.sql.SQLException
int getStatementDestroyerNumConnectionsWithDeferredDestroyStatementsDefaultUser() throws java.sql.SQLException
java.sql.SQLException
int getStatementDestroyerNumDeferredDestroyStatementsDefaultUser() throws java.sql.SQLException
java.sql.SQLException
java.lang.Throwable getLastAcquisitionFailure(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
java.lang.Throwable getLastCheckinFailure(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
java.lang.Throwable getLastCheckoutFailure(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
java.lang.Throwable getLastIdleTestFailure(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
java.lang.Throwable getLastConnectionTestFailure(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
int getStatementDestroyerNumConnectionsInUse(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
int getStatementDestroyerNumConnectionsWithDeferredDestroyStatements(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
int getStatementDestroyerNumDeferredDestroyStatements(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleLastAcquisitionFailureStackTraceDefaultUser() throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleLastCheckinFailureStackTraceDefaultUser() throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleLastCheckoutFailureStackTraceDefaultUser() throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleLastIdleTestFailureStackTraceDefaultUser() throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleLastConnectionTestFailureStackTraceDefaultUser() throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleLastAcquisitionFailureStackTrace(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleLastCheckinFailureStackTrace(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleLastCheckoutFailureStackTrace(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleLastIdleTestFailureStackTrace(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
java.lang.String sampleLastConnectionTestFailureStackTrace(java.lang.String username, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
void softResetAllUsers() throws java.sql.SQLException
java.sql.SQLException
int getNumUserPools() throws java.sql.SQLException
java.sql.SQLException
int getNumHelperThreads() throws java.sql.SQLException
java.sql.SQLException
java.util.Collection getAllUsers() throws java.sql.SQLException
java.sql.SQLException
void hardReset() throws java.sql.SQLException
java.sql.SQLException
void close() throws java.sql.SQLException
C3P0 pooled DataSources use no resources before they are actually used in a VM, and they close themselves in their finalize() method. When they are active and pooling, they may have open database connections and their pool may spawn several threads for its maintenance. You can use this method to clean these resource methods up quickly when you will no longer be using this DataSource. The resources will actually be cleaned up only if no other DataSources are sharing the same pool.
You can equivalently use the static method destroy() in the DataSources class to clean-up these resources.
This is equivalent to calling close( false ).
java.sql.SQLException
DataSources.destroy(javax.sql.DataSource)
void close(boolean force_destory) throws java.sql.SQLException
Should be used only with great caution. If force_destroy is set to true, this immediately destroys any pool and cleans up all resources this DataSource may be using, even if other DataSources are sharing that pool! In general, it is difficult to know whether a pool is being shared by multiple DataSources. It may depend upon whether or not a JNDI implementation returns a single instance or multiple copies upon lookup (which is undefined by the JNDI spec).
In general, this method should be used only when you wish to wind down all c3p0 pools in a ClassLoader. For example, when shutting down and restarting a web application that uses c3p0, you may wish to kill all threads making use of classes loaded by a web-app specific ClassLoader, so that the ClassLoader can be cleanly garbage collected. In this case, you may wish to use force destroy. Otherwise, it is much safer to use the simple destroy() method, which will not shut down pools that may still be in use.
To close a pool normally, use the no argument close method, or set force_destroy to false.
java.sql.SQLException
close()