Package org.apache.commons.dbcp2
Class PoolingDriver
java.lang.Object
org.apache.commons.dbcp2.PoolingDriver
- All Implemented Interfaces:
Driver
- Since:
- 2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intMajor version number.protected static final intMinor version number.protected static final HashMap<String, ObjectPool<? extends Connection>> The map of registered pools.static final StringThe Apache Commons connection string prefix "jdbc:apache:commons:dbcp:".protected static final intThe String length ofURL_PREFIX. -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructs a new driver withaccessToUnderlyingConnectionAllowedenabled.protectedPoolingDriver(boolean accessToUnderlyingConnectionAllowed) For unit testing purposes. -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptsURL(String url) voidCloses a named pool.connect(String url, Properties info) ObjectPool<? extends Connection> getConnectionPool(String name) Gets the connection pool for the given name.intintString[]Gets the pool names.getPropertyInfo(String url, Properties info) voidInvalidates the given connection.protected booleanReturns the value of the accessToUnderlyingConnectionAllowed property.booleanvoidregisterPool(String name, ObjectPool<? extends Connection> pool) Registers a named pool.
-
Field Details
-
pools
The map of registered pools. -
URL_PREFIX
The Apache Commons connection string prefix "jdbc:apache:commons:dbcp:".- See Also:
-
URL_PREFIX_LEN
The String length ofURL_PREFIX. -
MAJOR_VERSION
Major version number.- See Also:
-
MINOR_VERSION
Minor version number.- See Also:
-
-
Constructor Details
-
PoolingDriver
public PoolingDriver()Constructs a new driver withaccessToUnderlyingConnectionAllowedenabled. -
PoolingDriver
For unit testing purposes.- Parameters:
accessToUnderlyingConnectionAllowed- DoDelegatingConnections created by this driver permit access to the delegate?
-
-
Method Details
-
acceptsURL
- Specified by:
acceptsURLin interfaceDriver- Throws:
SQLException
-
closePool
Closes a named pool.- Parameters:
name- The pool name.- Throws:
SQLException- Thrown when a problem is caught closing the pool.
-
connect
- Specified by:
connectin interfaceDriver- Throws:
SQLException
-
getConnectionPool
Gets the connection pool for the given name.- Parameters:
name- The pool name- Returns:
- The pool
- Throws:
SQLException- Thrown when the named pool is not registered.
-
getMajorVersion
- Specified by:
getMajorVersionin interfaceDriver
-
getMinorVersion
- Specified by:
getMinorVersionin interfaceDriver
-
getParentLogger
- Specified by:
getParentLoggerin interfaceDriver- Throws:
SQLFeatureNotSupportedException
-
getPoolNames
Gets the pool names.- Returns:
- the pool names.
-
getPropertyInfo
- Specified by:
getPropertyInfoin interfaceDriver
-
invalidateConnection
Invalidates the given connection.- Parameters:
conn- connection to invalidate- Throws:
SQLException- if the connection is not aPoolGuardConnectionWrapperor an error occurs invalidating the connection
-
isAccessToUnderlyingConnectionAllowed
Returns the value of the accessToUnderlyingConnectionAllowed property.- Returns:
- true if access to the underlying is allowed, false otherwise.
-
jdbcCompliant
- Specified by:
jdbcCompliantin interfaceDriver
-
registerPool
Registers a named pool.- Parameters:
name- The pool name.pool- The pool.
-