Package org.apache.tomcat.dbcp.dbcp2
Class PoolingDriver
java.lang.Object
org.apache.tomcat.dbcp.dbcp2.PoolingDriver
- All Implemented Interfaces:
Driver
- Since:
- 2.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
Major version number.protected static final int
Minor version number.protected static final HashMap<String,
ObjectPool<? extends Connection>> The map of registered pools.static final String
The Apache Commons connection string prefix "jdbc:apache:commons:dbcp:".protected static final int
The String length ofURL_PREFIX
. -
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
The Apache Commons connection string prefix "jdbc:apache:commons:dbcp:".- See Also:
-
URL_PREFIX_LEN
protected static final int URL_PREFIX_LENThe String length ofURL_PREFIX
. -
MAJOR_VERSION
protected static final int MAJOR_VERSIONMajor version number.- See Also:
-
MINOR_VERSION
protected static final int MINOR_VERSIONMinor version number.- See Also:
-
-
Constructor Details
-
PoolingDriver
public PoolingDriver()Constructs a new driver withaccessToUnderlyingConnectionAllowed
enabled. -
PoolingDriver
protected PoolingDriver(boolean accessToUnderlyingConnectionAllowed) 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
public int getMajorVersion()- Specified by:
getMajorVersion
in interfaceDriver
-
getMinorVersion
public int 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
protected boolean isAccessToUnderlyingConnectionAllowed()Returns the value of the accessToUnderlyingConnectionAllowed property.- Returns:
- true if access to the underlying is allowed, false otherwise.
-
jdbcCompliant
public boolean jdbcCompliant()- Specified by:
jdbcCompliant
in interfaceDriver
-
registerPool
Registers a named pool.- Parameters:
name
- The pool name.pool
- The pool.
-