Package org.apache.commons.dbcp2
Class PoolingDriver
java.lang.Object
org.apache.commons.dbcp2.PoolingDriver
- All Implemented Interfaces:
Driver
- Since:
- 2.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
protected static final int
protected static final HashMap
<String, ObjectPool<? extends Connection>> The map of registered pools.static final String
My URL prefixprotected static final int
-
Constructor Summary
ModifierConstructorDescriptionConstructs a new driver withaccessToUnderlyingConnectionAllowed
enabled.protected
PoolingDriver
(boolean accessToUnderlyingConnectionAllowed) For unit testing purposes. -
Method Summary
Modifier and TypeMethodDescriptionboolean
acceptsURL
(String url) void
Closes a named pool.connect
(String url, Properties info) ObjectPool
<? extends Connection> getConnectionPool
(String name) Gets the connection pool for the given name.int
int
String[]
Gets the pool names.getPropertyInfo
(String url, Properties info) void
Invalidates the given connection.protected boolean
Returns the value of the accessToUnderlyingConnectionAllowed property.boolean
void
registerPool
(String name, ObjectPool<? extends Connection> pool) Registers a named pool.
-
Field Details
-
pools
The map of registered pools. -
URL_PREFIX
My URL prefix- See Also:
-
URL_PREFIX_LEN
-
MAJOR_VERSION
- See Also:
-
MINOR_VERSION
- See Also:
-
-
Constructor Details
-
PoolingDriver
public PoolingDriver()Constructs a new driver withaccessToUnderlyingConnectionAllowed
enabled. -
PoolingDriver
For unit testing purposes.- Parameters:
accessToUnderlyingConnectionAllowed
- DoDelegatingConnection
s created by this driver permit access to the delegate?
-
-
Method Details
-
acceptsURL
- Specified by:
acceptsURL
in 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:
connect
in 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:
getMajorVersion
in interfaceDriver
-
getMinorVersion
- Specified by:
getMinorVersion
in interfaceDriver
-
getParentLogger
- Specified by:
getParentLogger
in interfaceDriver
- Throws:
SQLFeatureNotSupportedException
-
getPoolNames
Gets the pool names.- Returns:
- the pool names.
-
getPropertyInfo
- Specified by:
getPropertyInfo
in interfaceDriver
-
invalidateConnection
Invalidates the given connection.- Parameters:
conn
- connection to invalidate- Throws:
SQLException
- if the connection is not aPoolGuardConnectionWrapper
or 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:
jdbcCompliant
in interfaceDriver
-
registerPool
Registers a named pool.- Parameters:
name
- The pool name.pool
- The pool.
-