public class PoolableConnectionFactory extends Object implements PooledObjectFactory<PoolableConnection>
PooledObjectFactory
that creates
PoolableConnection
s.Constructor and Description |
---|
PoolableConnectionFactory(ConnectionFactory connFactory,
ObjectName dataSourceJmxName)
Create a new PoolableConnectionFactory.
|
Modifier and Type | Method and Description |
---|---|
void |
activateObject(PooledObject<PoolableConnection> p) |
void |
destroyObject(PooledObject<PoolableConnection> p) |
protected boolean |
getCacheState() |
protected ConnectionFactory |
getConnectionFactory() |
Integer |
getDefaultQueryTimeout() |
protected int |
getMaxOpenPreparedStatements() |
ObjectPool<PoolableConnection> |
getPool()
Returns the
ObjectPool in which Connection s are pooled. |
protected boolean |
getPoolStatements() |
protected void |
initializeConnection(Connection conn) |
boolean |
isEnableAutoCommitOnReturn() |
boolean |
isRollbackOnReturn() |
PooledObject<PoolableConnection> |
makeObject() |
void |
passivateObject(PooledObject<PoolableConnection> p) |
void |
setCacheState(boolean cacheState) |
void |
setConnectionInitSql(Collection<String> connectionInitSqls)
Sets the SQL statements I use to initialize newly created
Connection s. |
void |
setDefaultAutoCommit(Boolean defaultAutoCommit)
Sets the default "auto commit" setting for borrowed
Connection s |
void |
setDefaultCatalog(String defaultCatalog)
Sets the default "catalog" setting for borrowed
Connection s |
void |
setDefaultQueryTimeout(Integer defaultQueryTimeout) |
void |
setDefaultReadOnly(Boolean defaultReadOnly)
Sets the default "read only" setting for borrowed
Connection s |
void |
setDefaultTransactionIsolation(int defaultTransactionIsolation)
Sets the default "Transaction Isolation" setting for borrowed
Connection s |
void |
setEnableAutoCommitOnReturn(boolean enableAutoCommitOnReturn) |
void |
setMaxConnLifetimeMillis(long maxConnLifetimeMillis)
Sets the maximum lifetime in milliseconds of a connection after which the
connection will always fail activation, passivation and validation.
|
void |
setMaxOpenPrepatedStatements(int maxOpenPreparedStatements) |
void |
setPool(ObjectPool<PoolableConnection> pool)
Sets the
ObjectPool in which to pool Connection s. |
void |
setPoolStatements(boolean poolStatements) |
void |
setRollbackOnReturn(boolean rollbackOnReturn) |
void |
setValidationQuery(String validationQuery)
Sets the query I use to
validate Connection s. |
void |
setValidationQueryTimeout(int timeout)
Sets the validation query timeout, the amount of time, in seconds, that
connection validation will wait for a response from the database when
executing a validation query.
|
void |
validateConnection(PoolableConnection conn) |
boolean |
validateObject(PooledObject<PoolableConnection> p) |
public PoolableConnectionFactory(ConnectionFactory connFactory, ObjectName dataSourceJmxName)
connFactory
- the ConnectionFactory
from which to obtain
base Connection
spublic void setValidationQuery(String validationQuery)
validate
Connection
s.
Should return at least one row. If not specified,
Connection.isValid(int)
will be used to validate connections.validationQuery
- a query to use to validate
Connection
s.public void setValidationQueryTimeout(int timeout)
timeout
- new validation query timeout value in secondspublic void setConnectionInitSql(Collection<String> connectionInitSqls)
Connection
s.
Using null turns off connection initialization.connectionInitSqls
- SQL statement to initialize Connection
s.public void setPool(ObjectPool<PoolableConnection> pool)
ObjectPool
in which to pool Connection
s.pool
- the ObjectPool
in which to pool those Connection
spublic ObjectPool<PoolableConnection> getPool()
ObjectPool
in which Connection
s are pooled.public void setDefaultReadOnly(Boolean defaultReadOnly)
Connection
sdefaultReadOnly
- the default "read only" setting for borrowed Connection
spublic void setDefaultAutoCommit(Boolean defaultAutoCommit)
Connection
sdefaultAutoCommit
- the default "auto commit" setting for borrowed Connection
spublic void setDefaultTransactionIsolation(int defaultTransactionIsolation)
Connection
sdefaultTransactionIsolation
- the default "Transaction Isolation" setting for returned Connection
spublic void setDefaultCatalog(String defaultCatalog)
Connection
sdefaultCatalog
- the default "catalog" setting for borrowed Connection
spublic void setCacheState(boolean cacheState)
public void setPoolStatements(boolean poolStatements)
public void setMaxOpenPrepatedStatements(int maxOpenPreparedStatements)
public void setMaxConnLifetimeMillis(long maxConnLifetimeMillis)
public boolean isEnableAutoCommitOnReturn()
public void setEnableAutoCommitOnReturn(boolean enableAutoCommitOnReturn)
public boolean isRollbackOnReturn()
public void setRollbackOnReturn(boolean rollbackOnReturn)
public Integer getDefaultQueryTimeout()
public void setDefaultQueryTimeout(Integer defaultQueryTimeout)
public PooledObject<PoolableConnection> makeObject() throws Exception
makeObject
in interface PooledObjectFactory<PoolableConnection>
Exception
protected void initializeConnection(Connection conn) throws SQLException
SQLException
public void destroyObject(PooledObject<PoolableConnection> p) throws Exception
destroyObject
in interface PooledObjectFactory<PoolableConnection>
Exception
public boolean validateObject(PooledObject<PoolableConnection> p)
validateObject
in interface PooledObjectFactory<PoolableConnection>
public void validateConnection(PoolableConnection conn) throws SQLException
SQLException
public void passivateObject(PooledObject<PoolableConnection> p) throws Exception
passivateObject
in interface PooledObjectFactory<PoolableConnection>
Exception
public void activateObject(PooledObject<PoolableConnection> p) throws Exception
activateObject
in interface PooledObjectFactory<PoolableConnection>
Exception
protected ConnectionFactory getConnectionFactory()
protected boolean getPoolStatements()
protected int getMaxOpenPreparedStatements()
protected boolean getCacheState()
Copyright © 2001–2014 The Apache Software Foundation. All rights reserved.