Package org.apache.commons.dbcp
Class PoolingDataSource
- java.lang.Object
-
- org.apache.commons.dbcp.PoolingDataSource
-
- All Implemented Interfaces:
java.sql.Wrapper,javax.sql.CommonDataSource,javax.sql.DataSource
- Direct Known Subclasses:
ManagedDataSource
public class PoolingDataSource extends java.lang.Object implements javax.sql.DataSourceA simpleDataSourceimplementation that obtainsConnections from the specifiedObjectPool.- 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 java.io.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 java.sql.ConnectiongetConnection()Return 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()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.voidsetPool(org.apache.commons.pool.ObjectPool pool)<T> Tunwrap(java.lang.Class<T> iface)
-
-
-
Method Detail
-
setPool
public void setPool(org.apache.commons.pool.ObjectPool pool) throws java.lang.IllegalStateException, java.lang.NullPointerException- Throws:
java.lang.IllegalStateExceptionjava.lang.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(java.lang.Class<?> iface) throws java.sql.SQLException- Specified by:
isWrapperForin interfacejava.sql.Wrapper- Throws:
java.sql.SQLException
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException- Specified by:
unwrapin interfacejava.sql.Wrapper- Throws:
java.sql.SQLException
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLExceptionReturn aConnectionfrom my pool, according to the contract specified byObjectPool.borrowObject().- Specified by:
getConnectionin interfacejavax.sql.DataSource- Throws:
java.sql.SQLException
-
getConnection
public java.sql.Connection getConnection(java.lang.String uname, java.lang.String passwd) throws java.sql.SQLExceptionThrowsUnsupportedOperationException- Specified by:
getConnectionin interfacejavax.sql.DataSource- Throws:
java.lang.UnsupportedOperationExceptionjava.sql.SQLException
-
getLogWriter
public java.io.PrintWriter getLogWriter()
Returns my log writer.- Specified by:
getLogWriterin interfacejavax.sql.CommonDataSource- Specified by:
getLogWriterin interfacejavax.sql.DataSource- Returns:
- my log writer
- See Also:
DataSource.getLogWriter()
-
getLoginTimeout
public int getLoginTimeout()
ThrowsUnsupportedOperationException.- Specified by:
getLoginTimeoutin interfacejavax.sql.CommonDataSource- Specified by:
getLoginTimeoutin interfacejavax.sql.DataSource- Throws:
java.lang.UnsupportedOperationException- As this implementation does not support this feature.
-
setLoginTimeout
public void setLoginTimeout(int seconds)
ThrowsUnsupportedOperationException.- Specified by:
setLoginTimeoutin interfacejavax.sql.CommonDataSource- Specified by:
setLoginTimeoutin interfacejavax.sql.DataSource- Throws:
java.lang.UnsupportedOperationException- As this implementation does not support this feature.
-
setLogWriter
public void setLogWriter(java.io.PrintWriter out)
Sets my log writer.- Specified by:
setLogWriterin interfacejavax.sql.CommonDataSource- Specified by:
setLogWriterin interfacejavax.sql.DataSource- See Also:
DataSource.setLogWriter(java.io.PrintWriter)
-
getParentLogger
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException- Specified by:
getParentLoggerin interfacejavax.sql.CommonDataSource- Throws:
java.sql.SQLFeatureNotSupportedException
-
-