Class PoolingDataSource<C extends Connection>
java.lang.Object
org.apache.commons.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
- Version:
- $Id: PoolingDataSource.java 1677110 2015-05-01 11:15:22Z sebb $
- Author:
- Rodney Waldhoff, Glenn L. Nielsen, James House, Dirk Verbeeck
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close and free allConnections from the pool.Return aConnectionfrom my pool, according to the contract specified byObjectPool.borrowObject().getConnection(String uname, String passwd) intThrowsUnsupportedOperationException.Returns my log writer.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 Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CommonDataSource
createShardingKeyBuilderMethods inherited from interface DataSource
createConnectionBuilder
-
Constructor Details
-
PoolingDataSource
-
-
Method Details
-
close
Close and free allConnections from the pool.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception- Since:
- 2.1
-
isAccessToUnderlyingConnectionAllowed
public boolean isAccessToUnderlyingConnectionAllowed()Returns the value of the accessToUnderlyingConnectionAllowed property.- Returns:
- true if access to the underlying
Connectionis 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
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
unwrap
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
getParentLogger
- Specified by:
getParentLoggerin interfaceCommonDataSource- Throws:
SQLFeatureNotSupportedException
-
getConnection
Return aConnectionfrom my pool, according to the contract specified byObjectPool.borrowObject().- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
getConnection
- Specified by:
getConnectionin interfaceDataSource- Throws:
UnsupportedOperationExceptionSQLException
-
getLogWriter
Returns my log writer.- Specified by:
getLogWriterin interfaceCommonDataSource- Specified by:
getLogWriterin interfaceDataSource- Returns:
- my log writer
- See Also:
-
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
Sets my log writer.- Specified by:
setLogWriterin interfaceCommonDataSource- Specified by:
setLogWriterin interfaceDataSource- See Also:
-