C
- The connection typepublic class PoolingDataSource<C extends Connection> extends Object implements DataSource, AutoCloseable
Constructor and Description |
---|
PoolingDataSource(ObjectPool<C> pool)
Constructs a new instance backed by the given connection pool.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes and free all
Connection s from the pool. |
Connection |
getConnection()
Returns a
Connection from my pool, according to the contract specified by
ObjectPool.borrowObject() . |
Connection |
getConnection(String uname,
String passwd)
|
int |
getLoginTimeout()
Throws
UnsupportedOperationException . |
PrintWriter |
getLogWriter()
Returns my log writer.
|
Logger |
getParentLogger() |
protected ObjectPool<C> |
getPool() |
boolean |
isAccessToUnderlyingConnectionAllowed()
Returns the value of the accessToUnderlyingConnectionAllowed property.
|
boolean |
isWrapperFor(Class<?> iface) |
void |
setAccessToUnderlyingConnectionAllowed(boolean allow)
Sets the value of the accessToUnderlyingConnectionAllowed property.
|
void |
setLoginTimeout(int seconds)
Throws
UnsupportedOperationException . |
void |
setLogWriter(PrintWriter out)
Sets my log writer.
|
<T> T |
unwrap(Class<T> iface) |
public PoolingDataSource(ObjectPool<C> pool)
pool
- the given connection pool.public void close() throws RuntimeException, SQLException
Connection
s from the pool.close
in interface AutoCloseable
RuntimeException
SQLException
public boolean isAccessToUnderlyingConnectionAllowed()
Connection
is allowed, false otherwise.public void setAccessToUnderlyingConnectionAllowed(boolean allow)
allow
- Access to the underlying connection is granted when true.public boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor
in interface Wrapper
SQLException
public <T> T unwrap(Class<T> iface) throws SQLException
unwrap
in interface Wrapper
SQLException
public Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger
in interface CommonDataSource
SQLFeatureNotSupportedException
public Connection getConnection() throws SQLException
Connection
from my pool, according to the contract specified by
ObjectPool.borrowObject()
.getConnection
in interface DataSource
SQLException
public Connection getConnection(String uname, String passwd) throws SQLException
getConnection
in interface DataSource
UnsupportedOperationException
- always thrownSQLException
public PrintWriter getLogWriter()
getLogWriter
in interface CommonDataSource
CommonDataSource.getLogWriter()
public int getLoginTimeout()
UnsupportedOperationException
.getLoginTimeout
in interface CommonDataSource
UnsupportedOperationException
- As this implementation does not support this feature.public void setLoginTimeout(int seconds)
UnsupportedOperationException
.setLoginTimeout
in interface CommonDataSource
UnsupportedOperationException
- As this implementation does not support this feature.public void setLogWriter(PrintWriter out)
setLogWriter
in interface CommonDataSource
CommonDataSource.setLogWriter(java.io.PrintWriter)
protected ObjectPool<C> getPool()
Copyright © 2001–2019 The Apache Software Foundation. All rights reserved.