Top Inners Fields Constructors Methods
com.mchange.v2.c3p0.impl

public final Class C3P0PooledConnectionPool

extends Object
Class Inheritance
Imports
com.mchange.v2.c3p0.stmt.*, com.mchange.v2.c3p0.ConnectionCustomizer, .SQLWarnings, .UnifiedConnectionTester, .WrapperConnectionPoolDataSource, .C3P0Registry, .ConnectionTester, .QueryConnectionTester, java.lang.reflect.Method, java.sql.Connection, .SQLException, .SQLWarning, java.util.LinkedList, .WeakHashMap, java.util.concurrent.locks.ReentrantLock, javax.sql.ConnectionEvent, .ConnectionEventListener, .ConnectionPoolDataSource, .PooledConnection, com.mchange.v1.db.sql.ConnectionUtils, com.mchange.v2.async.AsynchronousRunner, .ThreadPoolReportingAsynchronousRunner, com.mchange.v2.log.MLevel, .MLog, .MLogger, com.mchange.v2.resourcepool.CannotAcquireResourceException, .ResourcePool, .ResourcePoolException, .ResourcePoolFactory, .TimeoutException, com.mchange.v2.sql.SqlUtils

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
C3P0PooledConnectionPool.AbstractInternalUseLockManager

This "internal use lock" crap is a lot of ado about very little.

private static class
pack-priv class
private static class
private static interface
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final boolean
pack-priv final boolean
pack-priv final int
pack-priv final ConnectionEventListener
pack-priv final int
pack-priv final ConnectionTester
pack-priv final AsynchronousRunner
pack-priv final boolean
private static C3P0PooledConnectionPool.RequestBoundaryMarker
pack-priv final C3P0PooledConnectionPool.AbstractInternalUseLockManager
pack-priv static final MLogger
private static C3P0PooledConnectionPool.RequestBoundaryMarker
private C3P0PooledConnectionPool.RequestBoundaryMarker
pack-priv final C3P0PooledConnectionPool.Resurrectables
pack-priv final ResourcePool
pack-priv final GooGooStatementCache
pack-priv final AsynchronousRunner

Constructor Summary

AccessConstructor and Description
pack-priv
C3P0PooledConnectionPool(final ConnectionPoolDataSource cpds, final DbAuth auth, int min, int max, int start, int inc, int acq_retry_attempts, int acq_retry_delay, boolean break_after_acq_failure, int checkoutTimeout, final int connectionIsValidTimeout, int idleConnectionTestPeriod, int maxIdleTime, int maxIdleTimeExcessConnections, int maxConnectionAge, int propertyCycle, int unreturnedConnectionTimeout, boolean debugUnreturnedConnectionStackTraces, boolean forceSynchronousCheckins, final boolean testConnectionOnCheckout, final boolean testConnectionOnCheckin, boolean attemptResurrectOnCheckin, int maxStatements, int maxStatementsPerConnection, String markSessionBoundaries, final ConnectionTester connectionTester, final ConnectionCustomizer connectionCustomizer, final String testQuery, final ResourcePoolFactory fact, ThreadPoolReportingAsynchronousRunner taskRunner, ThreadPoolReportingAsynchronousRunner deferredStatementDestroyer, final String parentDataSourceIdentityToken)

Method Summary

Modifier and TypeMethod and Description
private void
private Object
public PooledConnection
public void
public void
close(boolean close_outstanding_connections)

public String
private synchronized C3P0PooledConnectionPool.RequestBoundaryMarker
public float
public Throwable
public Throwable
public Throwable
public Throwable
public Throwable
public int
public int
public long
public long
public long
public int
public int
public int
public long
public int
public int
public int
public int
public int
public int
public long
private void
private void
public void
reset()

Discards all Connections managed by the pool and reacquires new Connections to populate.

private Boolean
private Boolean
private boolean
private boolean
private void
private void
private void
private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ASYNCHRONOUS_CONNECTION_EVENT_LISTENERback to summary
private static final boolean ASYNCHRONOUS_CONNECTION_EVENT_LISTENER
c3p0PooledConnectionsback to summary
pack-priv final boolean c3p0PooledConnections
checkoutTimeoutback to summary
pack-priv final int checkoutTimeout
clback to summary
pack-priv final ConnectionEventListener cl
connectionIsValidTimeoutback to summary
pack-priv final int connectionIsValidTimeout
connectionTesterback to summary
pack-priv final ConnectionTester connectionTester
deferredStatementDestroyerback to summary
pack-priv final AsynchronousRunner deferredStatementDestroyer
disableSessionBoundariesback to summary
pack-priv final boolean disableSessionBoundaries
INTERFACE_REQUEST_BOUNDARY_MARKERback to summary
private static C3P0PooledConnectionPool.RequestBoundaryMarker INTERFACE_REQUEST_BOUNDARY_MARKER
internalUseLockManagerback to summary
pack-priv final C3P0PooledConnectionPool.AbstractInternalUseLockManager internalUseLockManager
loggerback to summary
pack-priv static final MLogger logger
NO_OP_REQUEST_BOUNDARY_MARKERback to summary
private static C3P0PooledConnectionPool.RequestBoundaryMarker NO_OP_REQUEST_BOUNDARY_MARKER
requestBoundaryMarkerback to summary
private C3P0PooledConnectionPool.RequestBoundaryMarker requestBoundaryMarker
resurrectablesback to summary
pack-priv final C3P0PooledConnectionPool.Resurrectables resurrectables
rpback to summary
pack-priv final ResourcePool rp
scacheback to summary
pack-priv final GooGooStatementCache scache
sharedTaskRunnerback to summary
pack-priv final AsynchronousRunner sharedTaskRunner

Constructor Detail

C3P0PooledConnectionPoolback to summary
pack-priv C3P0PooledConnectionPool(final ConnectionPoolDataSource cpds, final DbAuth auth, int min, int max, int start, int inc, int acq_retry_attempts, int acq_retry_delay, boolean break_after_acq_failure, int checkoutTimeout, final int connectionIsValidTimeout, int idleConnectionTestPeriod, int maxIdleTime, int maxIdleTimeExcessConnections, int maxConnectionAge, int propertyCycle, int unreturnedConnectionTimeout, boolean debugUnreturnedConnectionStackTraces, boolean forceSynchronousCheckins, final boolean testConnectionOnCheckout, final boolean testConnectionOnCheckin, boolean attemptResurrectOnCheckin, int maxStatements, int maxStatementsPerConnection, String markSessionBoundaries, final ConnectionTester connectionTester, final ConnectionCustomizer connectionCustomizer, final String testQuery, final ResourcePoolFactory fact, ThreadPoolReportingAsynchronousRunner taskRunner, ThreadPoolReportingAsynchronousRunner deferredStatementDestroyer, final String parentDataSourceIdentityToken) throws SQLException

Method Detail

checkinPooledConnectionback to summary
private void checkinPooledConnection(PooledConnection pcon) throws SQLException
checkoutAndScacheMarkConnectionInUseback to summary
private Object checkoutAndScacheMarkConnectionInUse() throws TimeoutException, CannotAcquireResourceException, ResourcePoolException, InterruptedException
checkoutPooledConnectionback to summary
public PooledConnection checkoutPooledConnection() throws SQLException
closeback to summary
public void close() throws SQLException
closeback to summary
public void close(boolean close_outstanding_connections) throws SQLException
dumpStatementCacheStatusback to summary
public String dumpStatementCacheStatus()
findRequestBoundaryMarkerback to summary
private synchronized C3P0PooledConnectionPool.RequestBoundaryMarker findRequestBoundaryMarker(PooledConnection pc)
getEffectivePropertyCycleback to summary
public float getEffectivePropertyCycle() throws SQLException
getLastAcquisitionFailureback to summary
public Throwable getLastAcquisitionFailure() throws SQLException
getLastCheckinFailureback to summary
public Throwable getLastCheckinFailure() throws SQLException
getLastCheckoutFailureback to summary
public Throwable getLastCheckoutFailure() throws SQLException
getLastConnectionTestFailureback to summary
public Throwable getLastConnectionTestFailure() throws SQLException
getLastIdleTestFailureback to summary
public Throwable getLastIdleTestFailure() throws SQLException
getNumBusyConnectionsback to summary
public int getNumBusyConnections() throws SQLException
getNumConnectionsback to summary
public int getNumConnections() throws SQLException
getNumFailedCheckinsback to summary
public long getNumFailedCheckins() throws SQLException
getNumFailedCheckoutsback to summary
public long getNumFailedCheckouts() throws SQLException
getNumFailedIdleTestsback to summary
public long getNumFailedIdleTests() throws SQLException
getNumIdleConnectionsback to summary
public int getNumIdleConnections() throws SQLException
getNumThreadsAwaitingCheckoutback to summary
public int getNumThreadsAwaitingCheckout() throws SQLException
getNumUnclosedOrphanedConnectionsback to summary
public int getNumUnclosedOrphanedConnections() throws SQLException
getStartTimeback to summary
public long getStartTime() throws SQLException
getStatementCacheNumCheckedOutback to summary
public int getStatementCacheNumCheckedOut()
getStatementCacheNumConnectionsWithCachedStatementsback to summary
public int getStatementCacheNumConnectionsWithCachedStatements()
getStatementCacheNumStatementsback to summary
public int getStatementCacheNumStatements()
getStatementDestroyerNumConnectionsInUseback to summary
public int getStatementDestroyerNumConnectionsInUse()
getStatementDestroyerNumConnectionsWithDeferredDestroyStatementsback to summary
public int getStatementDestroyerNumConnectionsWithDeferredDestroyStatements()
getStatementDestroyerNumDeferredDestroyStatementsback to summary
public int getStatementDestroyerNumDeferredDestroyStatements()
getUpTimeback to summary
public long getUpTime() throws SQLException
markBeginRequestback to summary
private void markBeginRequest(PooledConnection pc)
markEndRequestback to summary
private void markEndRequest(PooledConnection pc)
resetback to summary
public void reset() throws SQLException

Discards all Connections managed by the pool and reacquires new Connections to populate. Current checked out Connections will still be valid, and should still be checked into the pool (so the pool can destroy them).

scachePhysicalConnectionInUseback to summary
private Boolean scachePhysicalConnectionInUse(Connection physicalConnection) throws InterruptedException
scachePooledConnectionInUseback to summary
private Boolean scachePooledConnectionInUse(PooledConnection pc) throws InterruptedException
scacheTryMarkPhysicalConnectionInUseback to summary
private boolean scacheTryMarkPhysicalConnectionInUse(Connection physicalConnection)
scacheTryMarkPooledConnectionInUseback to summary
private boolean scacheTryMarkPooledConnectionInUse(PooledConnection pooledCon)
scacheUnmarkConnectionInUseAndCheckinback to summary
private void scacheUnmarkConnectionInUseAndCheckin(PooledConnection pcon) throws ResourcePoolException
scacheUnmarkPhysicalConnectionInUseback to summary
private void scacheUnmarkPhysicalConnectionInUse(Connection physicalConnection)
scacheUnmarkPooledConnectionInUseback to summary
private void scacheUnmarkPooledConnectionInUse(PooledConnection pooledCon)
scacheWaitMarkPhysicalConnectionInUseback to summary
private void scacheWaitMarkPhysicalConnectionInUse(Connection physicalConnection) throws InterruptedException
scacheWaitMarkPooledConnectionInUseback to summary
private void scacheWaitMarkPooledConnectionInUse(PooledConnection pooledCon) throws InterruptedException
com.mchange.v2.c3p0.impl back to summary

private abstract Class C3P0PooledConnectionPool.AbstractInternalUseLockManager

extends Object
Class Inheritance
  • java.lang.Object
  • com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.AbstractInternalUseLockManager
Known Direct Subclasses
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.WeakHashMapInternalUseLockManager, com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.C3P0PooledConnectionNestedLockInternalUseLockManager

This "internal use lock" crap is a lot of ado about very little. In theory, there is a hazard that pool maintenance tasks could get sufficiently backed up in the Thread pool that say, multple Connection tests might run simultaneously. That would be okay, but the Statement cache's "mark-in-use" functionality doesn't track nested use of resources. So we enforce exclusive, sequential execution of internal tests by requiring the tests hold a lock.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract ReentrantLock
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AbstractInternalUseLockManagerback to summary
private AbstractInternalUseLockManager()

Method Detail

getInternalUseLockback to summary
pack-priv abstract ReentrantLock getInternalUseLock(Object resc)
lockInternalUseback to summary
public void lockInternalUse(Object resc)
unlockInternalUseback to summary
public void unlockInternalUse(Object resc)
com.mchange.v2.c3p0.impl back to summary

private Class C3P0PooledConnectionPool.C3P0PooledConnectionNestedLockInternalUseLockManager

extends AbstractInternalUseLockManager
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv ReentrantLock
Inherited from com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.AbstractInternalUseLockManager:
lockInternalUseunlockInternalUse

Constructor Detail

C3P0PooledConnectionNestedLockInternalUseLockManagerback to summary
private C3P0PooledConnectionNestedLockInternalUseLockManager()

Method Detail

getInternalUseLockback to summary
pack-priv ReentrantLock getInternalUseLock(Object resc)

Implements abstract com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.AbstractInternalUseLockManager.getInternalUseLock.

com.mchange.v2.c3p0.impl back to summary

pack-priv Class C3P0PooledConnectionPool.ConnectionEventListenerImpl

extends Object
implements ConnectionEventListener
Class Inheritance
  • java.lang.Object
  • com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.ConnectionEventListenerImpl
All Implemented Interfaces
javax.sql.ConnectionEventListener, java.util.EventListener

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
connectionClosed(final ConnectionEvent
an event object describing the source of the event
evt
)

Implements javax.sql.ConnectionEventListener.connectionClosed.

Notifies this ConnectionEventListener that the application has called the method close on its representation of a pooled connection.

public void
connectionErrorOccurred(final ConnectionEvent
an event object describing the source of the event and containing the SQLException that the driver is about to throw
evt
)

Implements javax.sql.ConnectionEventListener.connectionErrorOccurred.

Notifies this ConnectionEventListener that a fatal error has occurred and the pooled connection can no longer be used.

private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ConnectionEventListenerImplback to summary
pack-priv ConnectionEventListenerImpl()

Method Detail

connectionClosedback to summary
public void connectionClosed(final ConnectionEvent evt)

Implements javax.sql.ConnectionEventListener.connectionClosed.

Doc from javax.sql.ConnectionEventListener.connectionClosed.

Notifies this ConnectionEventListener that the application has called the method close on its representation of a pooled connection.

Parameters
evt:ConnectionEvent

an event object describing the source of the event

connectionErrorOccurredback to summary
public void connectionErrorOccurred(final ConnectionEvent evt)

Implements javax.sql.ConnectionEventListener.connectionErrorOccurred.

Doc from javax.sql.ConnectionEventListener.connectionErrorOccurred.

Notifies this ConnectionEventListener that a fatal error has occurred and the pooled connection can no longer be used. The driver makes this notification just before it throws the application the SQLException contained in the given ConnectionEvent object.

Parameters
evt:ConnectionEvent

an event object describing the source of the event and containing the SQLException that the driver is about to throw

doCheckinResourceback to summary
private void doCheckinResource(ConnectionEvent evt)
doMarkPoolStatusback to summary
private void doMarkPoolStatus(PooledConnection pc, int status)
com.mchange.v2.c3p0.impl back to summary

private Class C3P0PooledConnectionPool.ReflectiveRequestBoundaryMarker

extends Object
implements RequestBoundaryMarker
Class Inheritance
  • java.lang.Object
  • com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.ReflectiveRequestBoundaryMarker
All Implemented Interfaces
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.RequestBoundaryMarker

Field Summary

Modifier and TypeField and Description
pack-priv Method
pack-priv Method

Constructor Summary

AccessConstructor and Description
pack-priv
ReflectiveRequestBoundaryMarker(Method beginRequest, Method endRequest)

Method Summary

Modifier and TypeMethod and Description
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beginRequestback to summary
pack-priv Method beginRequest
endRequestback to summary
pack-priv Method endRequest

Constructor Detail

ReflectiveRequestBoundaryMarkerback to summary
pack-priv ReflectiveRequestBoundaryMarker(Method beginRequest, Method endRequest)

Method Detail

attemptNotifyBeginRequestback to summary
public void attemptNotifyBeginRequest(PooledConnection pc)

Implements com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.RequestBoundaryMarker.attemptNotifyBeginRequest.

attemptNotifyEndRequestback to summary
public void attemptNotifyEndRequest(PooledConnection pc)

Implements com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.RequestBoundaryMarker.attemptNotifyEndRequest.

com.mchange.v2.c3p0.impl back to summary

private Interface C3P0PooledConnectionPool.RequestBoundaryMarker

Known Direct Implementers
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.ReflectiveRequestBoundaryMarker

Method Summary

Modifier and TypeMethod and Description
public void
public void

Method Detail

attemptNotifyBeginRequestback to summary
public void attemptNotifyBeginRequest(PooledConnection pc)
attemptNotifyEndRequestback to summary
public void attemptNotifyEndRequest(PooledConnection pc)
com.mchange.v2.c3p0.impl back to summary

private Class C3P0PooledConnectionPool.Resurrectables

extends Object
Class Inheritance
  • java.lang.Object
  • com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.Resurrectables

Field Summary

Modifier and TypeField and Description
pack-priv WeakHashMap<K, V>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public synchronized boolean
public synchronized void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

candidatesback to summary
pack-priv WeakHashMap<K, V> candidates

Constructor Detail

Resurrectablesback to summary
private Resurrectables()

Method Detail

checkResurrectableback to summary
public synchronized boolean checkResurrectable(Object resc)
markResurrectableback to summary
public synchronized void markResurrectable(Object resc)
com.mchange.v2.c3p0.impl back to summary

private Class C3P0PooledConnectionPool.WeakHashMapInternalUseLockManager

extends AbstractInternalUseLockManager
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv WeakHashMap<K, V>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv synchronized ReentrantLock
public synchronized void
public synchronized void

Field Detail

inUseLocksback to summary
pack-priv WeakHashMap<K, V> inUseLocks

Constructor Detail

WeakHashMapInternalUseLockManagerback to summary
private WeakHashMapInternalUseLockManager()

Method Detail

getInternalUseLockback to summary
pack-priv synchronized ReentrantLock getInternalUseLock(Object resc)

Implements abstract com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.AbstractInternalUseLockManager.getInternalUseLock.

lockInternalUseback to summary
public synchronized void lockInternalUse(Object resc)

Overrides com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.AbstractInternalUseLockManager.lockInternalUse.

unlockInternalUseback to summary
public synchronized void unlockInternalUse(Object resc)

Overrides com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.AbstractInternalUseLockManager.unlockInternalUse.