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:
<method-name>DefaultUser()<method-name>(String username, String password)<method-name>AllUsers()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.
hardReset() immediately closes all Connections managed by the DataSource, including
those that are currently checked out, bringing the DataSource back to the state it was in before
the first client called getConnection(). This method is obviously disruptive, and should be with
great care. Administrators who need to work around client applications that leak Connections, can
periodically poll for pool exhaustion (using the methods of this class, or by attempting to retrieve
a Connection and timing out) and use this method clean-up all Connections and start over. But calling
this method risks breaking Connections in current use by valid applications.softResetDefaultUser(), softReset( username, password ) and
softResetAllUsers() asks the DataSource to flush its current pool of Connections and
reacquire without invalidating currently checked-out Connections. Currently checked out Connections
are logically removed from the pool, but their destruction is deferred until a client attempts to close() / check-in
the Connection. Administrators who suspect that some Connections in the pool may be invalid, but who do not
wish to rely upon c3p0's automatic testing and detection mechanisms to resolve the problem, may call these
methods to force a refresh without disrupting current clients. Administrators who suspect that clients may be
leaking Connections may minimize disruptive hardReset() calls by using softReset() until the number of unclosed
orphaned connections reaches an unacceptable level. (See above to understand
why there are three variants of this method.)For each per-user pool, four different statistics are available:
numConnections represents the total number of Connections in the pool.numIdleConnections represents the number of Connections in the pool that are currently available for checkout.numBusyConnections represents the number of Connections in the pool that are currently checked out. The
invariant numIdleConnections + numBusyConnections == numConnections should always hold.numUnclosedOrphanedConnections will only be non-zero following a call to softReset(). It represents
the number of Connections that were checked out when a soft reset occurred and were therefore
silently excluded from the pool, and which remain unclosed by the client application.| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Redeclares java. C3P0 pooled DataSources use no resources before they are actually used in a VM, and they close themselves in their finalize() method. |
| public void | close(boolean force_destory)
Deprecated
the force_destroy argument is now meaningless, as pools are no longer
potentially shared between multiple DataSources.
Should be used only with great caution. |
| public Collection | |
| public String | |
| public float | |
| public float | |
| public Map | |
| public String | |
| public Throwable | |
| public Throwable | |
| public Throwable | |
| public Throwable | |
| public Throwable | |
| public Throwable | |
| public Throwable | |
| public Throwable | |
| public Throwable | |
| public Throwable | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public long | |
| public long | |
| public long | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public long | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public long | |
| public void | hardReset()
Destroys all pooled and checked-out Connections associated with this DataSource immediately. |
| public String | |
| public String | |
| public String | |
| public String | |
| public String | |
| public String | |
| public String | |
| public String | |
| public String | |
| public String | |
| public String | |
| public String | |
| public String | |
| public String | |
| public String | |
| public String | |
| public void | |
| public void | |
| public void | |
| public void | softResetAllUsers()
Discards all Connections managed by the PooledDataSource and reacquires new Connections to populate. |
| public void | softResetDefaultUser()
Discards all Connections managed by the PooledDataSource's default-authentication pool and reacquires new Connections to populate. |
| close | back to summary |
|---|---|
| public void close() throws SQLException Redeclares java. 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 ).
| |
| close | back to summary |
|---|---|
| public void close(boolean force_destory) throws SQLException
Deprecated the force_destroy argument is now meaningless, as pools are no longer potentially shared between multiple DataSources. Should be used only with great caution. If 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
| |
| getAllUsers | back to summary |
|---|---|
| public Collection | |
| getDataSourceName | back to summary |
|---|---|
| public String getDataSourceName() | |
| getEffectivePropertyCycle | back to summary |
|---|---|
| public float getEffectivePropertyCycle(String username, String password) throws SQLException | |
| getEffectivePropertyCycleDefaultUser | back to summary |
|---|---|
| public float getEffectivePropertyCycleDefaultUser() throws SQLException | |
| getExtensions | back to summary |
|---|---|
| public Map | |
| getIdentityToken | back to summary |
|---|---|
| public String getIdentityToken() | |
| getLastAcquisitionFailure | back to summary |
|---|---|
| public Throwable getLastAcquisitionFailure(String username, String password) throws SQLException | |
| getLastAcquisitionFailureDefaultUser | back to summary |
|---|---|
| public Throwable getLastAcquisitionFailureDefaultUser() throws SQLException | |
| getLastCheckinFailure | back to summary |
|---|---|
| public Throwable getLastCheckinFailure(String username, String password) throws SQLException | |
| getLastCheckinFailureDefaultUser | back to summary |
|---|---|
| public Throwable getLastCheckinFailureDefaultUser() throws SQLException | |
| getLastCheckoutFailure | back to summary |
|---|---|
| public Throwable getLastCheckoutFailure(String username, String password) throws SQLException | |
| getLastCheckoutFailureDefaultUser | back to summary |
|---|---|
| public Throwable getLastCheckoutFailureDefaultUser() throws SQLException | |
| getLastConnectionTestFailure | back to summary |
|---|---|
| public Throwable getLastConnectionTestFailure(String username, String password) throws SQLException | |
| getLastConnectionTestFailureDefaultUser | back to summary |
|---|---|
| public Throwable getLastConnectionTestFailureDefaultUser() throws SQLException | |
| getLastIdleTestFailure | back to summary |
|---|---|
| public Throwable getLastIdleTestFailure(String username, String password) throws SQLException | |
| getLastIdleTestFailureDefaultUser | back to summary |
|---|---|
| public Throwable getLastIdleTestFailureDefaultUser() throws SQLException | |
| getNumBusyConnections | back to summary |
|---|---|
| public int getNumBusyConnections() throws SQLException
Deprecated use getNumBusyConnectionsDefaultUser() | |
| getNumBusyConnections | back to summary |
|---|---|
| public int getNumBusyConnections(String username, String password) throws SQLException | |
| getNumBusyConnectionsAllUsers | back to summary |
|---|---|
| public int getNumBusyConnectionsAllUsers() throws SQLException | |
| getNumBusyConnectionsDefaultUser | back to summary |
|---|---|
| public int getNumBusyConnectionsDefaultUser() throws SQLException | |
| getNumConnections | back to summary |
|---|---|
| public int getNumConnections() throws SQLException
Deprecated use getNumConnectionsDefaultUser() | |
| getNumConnections | back to summary |
|---|---|
| public int getNumConnections(String username, String password) throws SQLException | |
| getNumConnectionsAllUsers | back to summary |
|---|---|
| public int getNumConnectionsAllUsers() throws SQLException | |
| getNumConnectionsDefaultUser | back to summary |
|---|---|
| public int getNumConnectionsDefaultUser() throws SQLException | |
| getNumFailedCheckinsDefaultUser | back to summary |
|---|---|
| public long getNumFailedCheckinsDefaultUser() throws SQLException | |
| getNumFailedCheckoutsDefaultUser | back to summary |
|---|---|
| public long getNumFailedCheckoutsDefaultUser() throws SQLException | |
| getNumFailedIdleTestsDefaultUser | back to summary |
|---|---|
| public long getNumFailedIdleTestsDefaultUser() throws SQLException | |
| getNumHelperThreads | back to summary |
|---|---|
| public int getNumHelperThreads() throws SQLException | |
| getNumIdleConnections | back to summary |
|---|---|
| public int getNumIdleConnections() throws SQLException
Deprecated use getNumIdleConnectionsDefaultUser() | |
| getNumIdleConnections | back to summary |
|---|---|
| public int getNumIdleConnections(String username, String password) throws SQLException | |
| getNumIdleConnectionsAllUsers | back to summary |
|---|---|
| public int getNumIdleConnectionsAllUsers() throws SQLException | |
| getNumIdleConnectionsDefaultUser | back to summary |
|---|---|
| public int getNumIdleConnectionsDefaultUser() throws SQLException | |
| getNumThreadsAwaitingCheckout | back to summary |
|---|---|
| public int getNumThreadsAwaitingCheckout(String username, String password) throws SQLException | |
| getNumThreadsAwaitingCheckoutDefaultUser | back to summary |
|---|---|
| public int getNumThreadsAwaitingCheckoutDefaultUser() throws SQLException | |
| getNumUnclosedOrphanedConnections | back to summary |
|---|---|
| public int getNumUnclosedOrphanedConnections() throws SQLException
Deprecated use getNumUnclosedOrphanedConnectionsDefaultUser() | |
| getNumUnclosedOrphanedConnections | back to summary |
|---|---|
| public int getNumUnclosedOrphanedConnections(String username, String password) throws SQLException | |
| getNumUnclosedOrphanedConnectionsAllUsers | back to summary |
|---|---|
| public int getNumUnclosedOrphanedConnectionsAllUsers() throws SQLException | |
| getNumUnclosedOrphanedConnectionsDefaultUser | back to summary |
|---|---|
| public int getNumUnclosedOrphanedConnectionsDefaultUser() throws SQLException | |
| getNumUserPools | back to summary |
|---|---|
| public int getNumUserPools() throws SQLException | |
| getStartTimeMillisDefaultUser | back to summary |
|---|---|
| public long getStartTimeMillisDefaultUser() throws SQLException | |
| getStatementCacheNumCheckedOut | back to summary |
|---|---|
| public int getStatementCacheNumCheckedOut(String username, String password) throws SQLException | |
| getStatementCacheNumCheckedOutDefaultUser | back to summary |
|---|---|
| public int getStatementCacheNumCheckedOutDefaultUser() throws SQLException | |
| getStatementCacheNumCheckedOutStatementsAllUsers | back to summary |
|---|---|
| public int getStatementCacheNumCheckedOutStatementsAllUsers() throws SQLException | |
| getStatementCacheNumConnectionsWithCachedStatements | back to summary |
|---|---|
| public int getStatementCacheNumConnectionsWithCachedStatements(String username, String password) throws SQLException | |
| getStatementCacheNumConnectionsWithCachedStatementsAllUsers | back to summary |
|---|---|
| public int getStatementCacheNumConnectionsWithCachedStatementsAllUsers() throws SQLException | |
| getStatementCacheNumConnectionsWithCachedStatementsDefaultUser | back to summary |
|---|---|
| public int getStatementCacheNumConnectionsWithCachedStatementsDefaultUser() throws SQLException | |
| getStatementCacheNumStatements | back to summary |
|---|---|
| public int getStatementCacheNumStatements(String username, String password) throws SQLException | |
| getStatementCacheNumStatementsAllUsers | back to summary |
|---|---|
| public int getStatementCacheNumStatementsAllUsers() throws SQLException | |
| getStatementCacheNumStatementsDefaultUser | back to summary |
|---|---|
| public int getStatementCacheNumStatementsDefaultUser() throws SQLException | |
| getStatementDestroyerNumActiveThreads | back to summary |
|---|---|
| public int getStatementDestroyerNumActiveThreads() throws SQLException | |
| getStatementDestroyerNumConnectionsInUse | back to summary |
|---|---|
| public int getStatementDestroyerNumConnectionsInUse(String username, String password) throws SQLException | |
| getStatementDestroyerNumConnectionsInUseAllUsers | back to summary |
|---|---|
| public int getStatementDestroyerNumConnectionsInUseAllUsers() throws SQLException | |
| getStatementDestroyerNumConnectionsInUseDefaultUser | back to summary |
|---|---|
| public int getStatementDestroyerNumConnectionsInUseDefaultUser() throws SQLException | |
| getStatementDestroyerNumConnectionsWithDeferredDestroyStatements | back to summary |
|---|---|
| public int getStatementDestroyerNumConnectionsWithDeferredDestroyStatements(String username, String password) throws SQLException | |
| getStatementDestroyerNumConnectionsWithDeferredDestroyStatementsAllUsers | back to summary |
|---|---|
| public int getStatementDestroyerNumConnectionsWithDeferredDestroyStatementsAllUsers() throws SQLException | |
| getStatementDestroyerNumConnectionsWithDeferredDestroyStatementsDefaultUser | back to summary |
|---|---|
| public int getStatementDestroyerNumConnectionsWithDeferredDestroyStatementsDefaultUser() throws SQLException | |
| getStatementDestroyerNumDeferredDestroyStatements | back to summary |
|---|---|
| public int getStatementDestroyerNumDeferredDestroyStatements(String username, String password) throws SQLException | |
| getStatementDestroyerNumDeferredDestroyStatementsAllUsers | back to summary |
|---|---|
| public int getStatementDestroyerNumDeferredDestroyStatementsAllUsers() throws SQLException | |
| getStatementDestroyerNumDeferredDestroyStatementsDefaultUser | back to summary |
|---|---|
| public int getStatementDestroyerNumDeferredDestroyStatementsDefaultUser() throws SQLException | |
| getStatementDestroyerNumIdleThreads | back to summary |
|---|---|
| public int getStatementDestroyerNumIdleThreads() throws SQLException | |
| getStatementDestroyerNumTasksPending | back to summary |
|---|---|
| public int getStatementDestroyerNumTasksPending() throws SQLException | |
| getStatementDestroyerNumThreads | back to summary |
|---|---|
| public int getStatementDestroyerNumThreads() throws SQLException | |
| getThreadPoolNumActiveThreads | back to summary |
|---|---|
| public int getThreadPoolNumActiveThreads() throws SQLException | |
| getThreadPoolNumIdleThreads | back to summary |
|---|---|
| public int getThreadPoolNumIdleThreads() throws SQLException | |
| getThreadPoolNumTasksPending | back to summary |
|---|---|
| public int getThreadPoolNumTasksPending() throws SQLException | |
| getThreadPoolSize | back to summary |
|---|---|
| public int getThreadPoolSize() throws SQLException | |
| getUpTimeMillisDefaultUser | back to summary |
|---|---|
| public long getUpTimeMillisDefaultUser() throws SQLException | |
| hardReset | back to summary |
|---|---|
| public void hardReset() throws SQLException Destroys all pooled and checked-out Connections associated with this DataSource immediately. The PooledDataSource is reset to its initial state prior to first Connection acquisition, with no pools yet active, but ready for requests. | |
| sampleLastAcquisitionFailureStackTrace | back to summary |
|---|---|
| public String sampleLastAcquisitionFailureStackTrace(String username, String password) throws SQLException | |
| sampleLastAcquisitionFailureStackTraceDefaultUser | back to summary |
|---|---|
| public String sampleLastAcquisitionFailureStackTraceDefaultUser() throws SQLException | |
| sampleLastCheckinFailureStackTrace | back to summary |
|---|---|
| public String sampleLastCheckinFailureStackTrace(String username, String password) throws SQLException | |
| sampleLastCheckinFailureStackTraceDefaultUser | back to summary |
|---|---|
| public String sampleLastCheckinFailureStackTraceDefaultUser() throws SQLException | |
| sampleLastCheckoutFailureStackTrace | back to summary |
|---|---|
| public String sampleLastCheckoutFailureStackTrace(String username, String password) throws SQLException | |
| sampleLastCheckoutFailureStackTraceDefaultUser | back to summary |
|---|---|
| public String sampleLastCheckoutFailureStackTraceDefaultUser() throws SQLException | |
| sampleLastConnectionTestFailureStackTrace | back to summary |
|---|---|
| public String sampleLastConnectionTestFailureStackTrace(String username, String password) throws SQLException | |
| sampleLastConnectionTestFailureStackTraceDefaultUser | back to summary |
|---|---|
| public String sampleLastConnectionTestFailureStackTraceDefaultUser() throws SQLException | |
| sampleLastIdleTestFailureStackTrace | back to summary |
|---|---|
| public String sampleLastIdleTestFailureStackTrace(String username, String password) throws SQLException | |
| sampleLastIdleTestFailureStackTraceDefaultUser | back to summary |
|---|---|
| public String sampleLastIdleTestFailureStackTraceDefaultUser() throws SQLException | |
| sampleStatementCacheStatus | back to summary |
|---|---|
| public String sampleStatementCacheStatus(String username, String password) throws SQLException | |
| sampleStatementCacheStatusDefaultUser | back to summary |
|---|---|
| public String sampleStatementCacheStatusDefaultUser() throws SQLException | |
| sampleStatementDestroyerStackTraces | back to summary |
|---|---|
| public String sampleStatementDestroyerStackTraces() throws SQLException | |
| sampleStatementDestroyerStatus | back to summary |
|---|---|
| public String sampleStatementDestroyerStatus() throws SQLException | |
| sampleThreadPoolStackTraces | back to summary |
|---|---|
| public String sampleThreadPoolStackTraces() throws SQLException | |
| sampleThreadPoolStatus | back to summary |
|---|---|
| public String sampleThreadPoolStatus() throws SQLException | |
| setDataSourceName | back to summary |
|---|---|
| public void setDataSourceName(String dataSourceName) | |
| setExtensions | back to summary |
|---|---|
| public void setExtensions(Map<K, V> extensions) | |
| softReset | back to summary |
|---|---|
| public void softReset(String username, String password) throws SQLException Discards all Connections managed by the PooledDataSource with the specified authentication credentials and reacquires new Connections to populate. Current checked out Connections will still be valid, and should still be checked into the PooledDataSource (so the PooledDataSource can destroy them). | |
| softResetAllUsers | back to summary |
|---|---|
| public void softResetAllUsers() throws SQLException Discards all Connections managed by the PooledDataSource and reacquires new Connections to populate. Current checked out Connections will still be valid, and should still be checked into the PooledDataSource (so the PooledDataSource can destroy them). | |
| softResetDefaultUser | back to summary |
|---|---|
| public void softResetDefaultUser() throws SQLException Discards all Connections managed by the PooledDataSource's default-authentication pool and reacquires new Connections to populate. Current checked out Connections will still be valid, and should still be checked into the PooledDataSource (so the PooledDataSource can destroy them). | |