Package org.apache.commons.dbcp
Class PoolingDataSource
- java.lang.Object
-
- org.apache.commons.dbcp.PoolingDataSource
-
- All Implemented Interfaces:
Wrapper,CommonDataSource,DataSource
- Direct Known Subclasses:
ManagedDataSource
public class PoolingDataSource extends Object implements DataSource
- Version:
- $Revision: 895844 $ $Date: 2010-01-04 20:50:04 -0500 (Mon, 04 Jan 2010) $
- Author:
- Rodney Waldhoff, Glenn L. Nielsen, James House, Dirk Verbeeck
-
-
Field Summary
Fields Modifier and Type Field Description protected PrintWriter_logWriterMy log writer.protected org.apache.commons.pool.ObjectPool_pool
-
Constructor Summary
Constructors Constructor Description PoolingDataSource()PoolingDataSource(org.apache.commons.pool.ObjectPool pool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectiongetConnection()Return aConnectionfrom my pool, according to the contract specified byObjectPool.borrowObject().ConnectiongetConnection(String uname, String passwd)intgetLoginTimeout()ThrowsUnsupportedOperationException.PrintWritergetLogWriter()Returns my log writer.LoggergetParentLogger()booleanisAccessToUnderlyingConnectionAllowed()Returns 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.voidsetPool(org.apache.commons.pool.ObjectPool pool)<T> Tunwrap(Class<T> iface)-
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
-
-
-
-
Field Detail
-
_logWriter
protected PrintWriter _logWriter
My log writer.
-
_pool
protected org.apache.commons.pool.ObjectPool _pool
-
-
Method Detail
-
setPool
public void setPool(org.apache.commons.pool.ObjectPool pool) throws IllegalStateException, NullPointerException
-
isAccessToUnderlyingConnectionAllowed
public boolean isAccessToUnderlyingConnectionAllowed()
Returns the value of the accessToUnderlyingConnectionAllowed property.- Returns:
- true if access to the underlying is allowed, false otherwise.
-
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.
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
getConnection
public Connection getConnection() throws SQLException
Return aConnectionfrom my pool, according to the contract specified byObjectPool.borrowObject().- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
getConnection
public Connection getConnection(String uname, String passwd) throws SQLException
- Specified by:
getConnectionin interfaceDataSource- Throws:
UnsupportedOperationExceptionSQLException
-
getLogWriter
public PrintWriter getLogWriter()
Returns my log writer.- Specified by:
getLogWriterin interfaceCommonDataSource- Specified by:
getLogWriterin interfaceDataSource- Returns:
- my log writer
- See Also:
DataSource.getLogWriter()
-
getLoginTimeout
public int getLoginTimeout()
ThrowsUnsupportedOperationException.- Specified by:
getLoginTimeoutin interfaceCommonDataSource- Specified by:
getLoginTimeoutin interfaceDataSource- Throws:
UnsupportedOperationException- As this implementation does not support this feature.
-
setLoginTimeout
public void setLoginTimeout(int seconds)
ThrowsUnsupportedOperationException.- Specified by:
setLoginTimeoutin interfaceCommonDataSource- Specified by:
setLoginTimeoutin interfaceDataSource- Throws:
UnsupportedOperationException- As this implementation does not support this feature.
-
setLogWriter
public void setLogWriter(PrintWriter out)
Sets my log writer.- Specified by:
setLogWriterin interfaceCommonDataSource- Specified by:
setLogWriterin interfaceDataSource- See Also:
DataSource.setLogWriter(java.io.PrintWriter)
-
getParentLogger
public Logger getParentLogger() throws SQLFeatureNotSupportedException
- Specified by:
getParentLoggerin interfaceCommonDataSource- Throws:
SQLFeatureNotSupportedException
-
-