Package org.apache.tomcat.dbcp.dbcp2
Class PoolingDataSource<C extends Connection>
java.lang.Object
org.apache.tomcat.dbcp.dbcp2.PoolingDataSource<C>
- Type Parameters:
C
- The connection type
- All Implemented Interfaces:
AutoCloseable
,Wrapper
,CommonDataSource
,DataSource
- Direct Known Subclasses:
ManagedDataSource
public class PoolingDataSource<C extends Connection>
extends Object
implements DataSource, AutoCloseable
- Since:
- 2.0
-
Constructor Summary
ConstructorDescriptionPoolingDataSource
(ObjectPool<C> pool) Constructs a new instance backed by the given connection pool. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes and free allConnection
s from the pool.Returns aConnection
from my pool, according to the contract specified byObjectPool.borrowObject()
.getConnection
(String userName, String password) int
ThrowsUnsupportedOperationException
.Returns my log writer.protected ObjectPool
<C> getPool()
boolean
Returns the value of the accessToUnderlyingConnectionAllowed property.boolean
isWrapperFor
(Class<?> iface) void
setAccessToUnderlyingConnectionAllowed
(boolean allow) Sets the value of the accessToUnderlyingConnectionAllowed property.void
setLoginTimeout
(int seconds) ThrowsUnsupportedOperationException
.void
setLogWriter
(PrintWriter out) Sets my log writer.<T> T
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
Constructor Details
-
PoolingDataSource
Constructs a new instance backed by the given connection pool.- Parameters:
pool
- the given connection pool.
-
-
Method Details
-
close
Closes and free allConnection
s from the pool.- Specified by:
close
in interfaceAutoCloseable
- Throws:
SQLException
- Since:
- 2.1
-
getConnection
Returns aConnection
from my pool, according to the contract specified byObjectPool.borrowObject()
.- Specified by:
getConnection
in interfaceDataSource
- Throws:
SQLException
-
getConnection
- Specified by:
getConnection
in interfaceDataSource
- Throws:
UnsupportedOperationException
- always thrownSQLException
-
getLoginTimeout
public int getLoginTimeout()ThrowsUnsupportedOperationException
.- Specified by:
getLoginTimeout
in interfaceCommonDataSource
- Specified by:
getLoginTimeout
in interfaceDataSource
- Throws:
UnsupportedOperationException
- As this implementation does not support this feature.
-
getLogWriter
Returns my log writer.- Specified by:
getLogWriter
in interfaceCommonDataSource
- Specified by:
getLogWriter
in interfaceDataSource
- Returns:
- my log writer
- See Also:
-
getParentLogger
- Specified by:
getParentLogger
in interfaceCommonDataSource
- Throws:
SQLFeatureNotSupportedException
-
getPool
-
isAccessToUnderlyingConnectionAllowed
public boolean isAccessToUnderlyingConnectionAllowed()Returns the value of the accessToUnderlyingConnectionAllowed property.- Returns:
- true if access to the underlying
Connection
is allowed, false otherwise.
-
isWrapperFor
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
setAccessToUnderlyingConnectionAllowed
public void setAccessToUnderlyingConnectionAllowed(boolean allow) Sets the value of the accessToUnderlyingConnectionAllowed property. It controls if the PoolGuard allows access to the underlying connection. (Default: false)- Parameters:
allow
- Access to the underlying connection is granted when true.
-
setLoginTimeout
public void setLoginTimeout(int seconds) ThrowsUnsupportedOperationException
.- Specified by:
setLoginTimeout
in interfaceCommonDataSource
- Specified by:
setLoginTimeout
in interfaceDataSource
- Throws:
UnsupportedOperationException
- As this implementation does not support this feature.
-
setLogWriter
Sets my log writer.- Specified by:
setLogWriter
in interfaceCommonDataSource
- Specified by:
setLogWriter
in interfaceDataSource
- See Also:
-
unwrap
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-