Package org.apache.tomcat.dbcp.dbcp2
Class PoolingDataSource<C extends java.sql.Connection>
- java.lang.Object
- 
- org.apache.tomcat.dbcp.dbcp2.PoolingDataSource<C>
 
- 
- Type Parameters:
- C- The connection type
 - All Implemented Interfaces:
- java.lang.AutoCloseable,- java.sql.Wrapper,- javax.sql.CommonDataSource,- javax.sql.DataSource
 
 public class PoolingDataSource<C extends java.sql.Connection> extends java.lang.Object implements javax.sql.DataSource, java.lang.AutoCloseable- Since:
- 2.0
 
- 
- 
Constructor SummaryConstructors Constructor Description PoolingDataSource(ObjectPool<C> pool)Constructs a new instance backed by the given connection pool.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes and free allConnections from the pool.java.sql.ConnectiongetConnection()Returns aConnectionfrom my pool, according to the contract specified byObjectPool.borrowObject().java.sql.ConnectiongetConnection(java.lang.String uname, java.lang.String passwd)ThrowsUnsupportedOperationExceptionintgetLoginTimeout()ThrowsUnsupportedOperationException.java.io.PrintWritergetLogWriter()Returns my log writer.java.util.logging.LoggergetParentLogger()protected ObjectPool<C>getPool()booleanisAccessToUnderlyingConnectionAllowed()Returns the value of the accessToUnderlyingConnectionAllowed property.booleanisWrapperFor(java.lang.Class<?> iface)voidsetAccessToUnderlyingConnectionAllowed(boolean allow)Sets the value of the accessToUnderlyingConnectionAllowed property.voidsetLoginTimeout(int seconds)ThrowsUnsupportedOperationException.voidsetLogWriter(java.io.PrintWriter out)Sets my log writer.<T> Tunwrap(java.lang.Class<T> iface)
 
- 
- 
- 
Constructor Detail- 
PoolingDataSourcepublic PoolingDataSource(ObjectPool<C> pool) Constructs a new instance backed by the given connection pool.- Parameters:
- pool- the given connection pool.
 
 
- 
 - 
Method Detail- 
closepublic void close() throws java.lang.RuntimeException, java.sql.SQLExceptionCloses and free allConnections from the pool.- Specified by:
- closein interface- java.lang.AutoCloseable
- Throws:
- java.lang.RuntimeException
- java.sql.SQLException
- Since:
- 2.1
 
 - 
isAccessToUnderlyingConnectionAllowedpublic boolean isAccessToUnderlyingConnectionAllowed() Returns the value of the accessToUnderlyingConnectionAllowed property.- Returns:
- true if access to the underlying Connectionis allowed, false otherwise.
 
 - 
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.
 
 - 
isWrapperForpublic boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException- Specified by:
- isWrapperForin interface- java.sql.Wrapper
- Throws:
- java.sql.SQLException
 
 - 
unwrappublic <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException- Specified by:
- unwrapin interface- java.sql.Wrapper
- Throws:
- java.sql.SQLException
 
 - 
getParentLoggerpublic java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException- Specified by:
- getParentLoggerin interface- javax.sql.CommonDataSource
- Throws:
- java.sql.SQLFeatureNotSupportedException
 
 - 
getConnectionpublic java.sql.Connection getConnection() throws java.sql.SQLExceptionReturns aConnectionfrom my pool, according to the contract specified byObjectPool.borrowObject().- Specified by:
- getConnectionin interface- javax.sql.DataSource
- Throws:
- java.sql.SQLException
 
 - 
getConnectionpublic java.sql.Connection getConnection(java.lang.String uname, java.lang.String passwd) throws java.sql.SQLExceptionThrowsUnsupportedOperationException- Specified by:
- getConnectionin interface- javax.sql.DataSource
- Throws:
- java.lang.UnsupportedOperationException- always thrown
- java.sql.SQLException
 
 - 
getLogWriterpublic java.io.PrintWriter getLogWriter() Returns my log writer.- Specified by:
- getLogWriterin interface- javax.sql.CommonDataSource
- Specified by:
- getLogWriterin interface- javax.sql.DataSource
- Returns:
- my log writer
- See Also:
- DataSource.getLogWriter()
 
 - 
getLoginTimeoutpublic int getLoginTimeout() ThrowsUnsupportedOperationException.- Specified by:
- getLoginTimeoutin interface- javax.sql.CommonDataSource
- Specified by:
- getLoginTimeoutin interface- javax.sql.DataSource
- Throws:
- java.lang.UnsupportedOperationException- As this implementation does not support this feature.
 
 - 
setLoginTimeoutpublic void setLoginTimeout(int seconds) ThrowsUnsupportedOperationException.- Specified by:
- setLoginTimeoutin interface- javax.sql.CommonDataSource
- Specified by:
- setLoginTimeoutin interface- javax.sql.DataSource
- Throws:
- java.lang.UnsupportedOperationException- As this implementation does not support this feature.
 
 - 
setLogWriterpublic void setLogWriter(java.io.PrintWriter out) Sets my log writer.- Specified by:
- setLogWriterin interface- javax.sql.CommonDataSource
- Specified by:
- setLogWriterin interface- javax.sql.DataSource
- See Also:
- DataSource.setLogWriter(java.io.PrintWriter)
 
 - 
getPoolprotected ObjectPool<C> getPool() 
 
- 
 
-