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 SummaryConstructorsConstructorDescriptionPoolingDataSource(ObjectPool<C> pool) Constructs a new instance backed by the given connection pool.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Closes and free allConnections from the pool.Returns aConnectionfrom my pool, according to the contract specified byObjectPool.borrowObject().getConnection(String uname, String passwd) intThrowsUnsupportedOperationException.Returns my log writer.protected ObjectPool<C>getPool()booleanReturns the value of the accessToUnderlyingConnectionAllowed property.booleanisWrapperFor(Class<?> iface) voidsetAccessToUnderlyingConnectionAllowed(boolean allow) Sets the value of the accessToUnderlyingConnectionAllowed property.voidsetLoginTimeout(int seconds) ThrowsUnsupportedOperationException.voidsetLogWriter(PrintWriter out) Sets my log writer.<T> TMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.sql.CommonDataSourcecreateShardingKeyBuilderMethods inherited from interface javax.sql.DataSourcecreateConnectionBuilder
- 
Constructor Details- 
PoolingDataSourceConstructs a new instance backed by the given connection pool.- Parameters:
- pool- the given connection pool.
 
 
- 
- 
Method Details- 
closeCloses and free allConnections from the pool.- Specified by:
- closein interface- AutoCloseable
- Throws:
- RuntimeException
- SQLException
- Since:
- 2.1
 
- 
getConnectionReturns aConnectionfrom my pool, according to the contract specified byObjectPool.borrowObject().- Specified by:
- getConnectionin interface- DataSource
- Throws:
- SQLException
 
- 
getConnection- Specified by:
- getConnectionin interface- DataSource
- Throws:
- UnsupportedOperationException- always thrown
- SQLException
 
- 
getLoginTimeoutpublic int getLoginTimeout()ThrowsUnsupportedOperationException.- Specified by:
- getLoginTimeoutin interface- CommonDataSource
- Specified by:
- getLoginTimeoutin interface- DataSource
- Throws:
- UnsupportedOperationException- As this implementation does not support this feature.
 
- 
getLogWriterReturns my log writer.- Specified by:
- getLogWriterin interface- CommonDataSource
- Specified by:
- getLogWriterin interface- DataSource
- Returns:
- my log writer
- See Also:
 
- 
getParentLogger- Specified by:
- getParentLoggerin interface- CommonDataSource
- Throws:
- SQLFeatureNotSupportedException
 
- 
getPool
- 
isAccessToUnderlyingConnectionAllowedpublic boolean isAccessToUnderlyingConnectionAllowed()Returns the value of the accessToUnderlyingConnectionAllowed property.- Returns:
- true if access to the underlying Connectionis allowed, false otherwise.
 
- 
isWrapperFor- Specified by:
- isWrapperForin interface- Wrapper
- Throws:
- SQLException
 
- 
setAccessToUnderlyingConnectionAllowedpublic 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.
 
- 
setLoginTimeoutpublic void setLoginTimeout(int seconds) ThrowsUnsupportedOperationException.- Specified by:
- setLoginTimeoutin interface- CommonDataSource
- Specified by:
- setLoginTimeoutin interface- DataSource
- Throws:
- UnsupportedOperationException- As this implementation does not support this feature.
 
- 
setLogWriterSets my log writer.- Specified by:
- setLogWriterin interface- CommonDataSource
- Specified by:
- setLogWriterin interface- DataSource
- See Also:
 
- 
unwrap- Specified by:
- unwrapin interface- Wrapper
- Throws:
- SQLException
 
 
-