net.sf.farrago.namespace.jdbc
Class MedJdbcDataServer.CustomPoolableConnectionFactory
java.lang.Object
net.sf.farrago.namespace.jdbc.MedJdbcDataServer.CustomPoolableConnectionFactory
- All Implemented Interfaces:
- org.apache.commons.pool.PoolableObjectFactory
- Enclosing class:
- MedJdbcDataServer
private class MedJdbcDataServer.CustomPoolableConnectionFactory
- extends Object
- implements org.apache.commons.pool.PoolableObjectFactory
CustomPoolableConnectionFactory is similar to DBCP's PoolableConnectionFactory
, but allows us to better control when Connection.setAutoCommit(boolean)
and Connection.setReadOnly(boolean)
are called. DBCP's implementation always
calls at least setAutoCommit
.
Examples: HSQLDB's setReadOnly(false)
throws if read-only
mode is enabled in the URL. CsvJdbc's setAutoCommit(boolean)
always throws.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
connectionFactory
private org.apache.commons.dbcp.ConnectionFactory connectionFactory
objectPool
private org.apache.commons.pool.ObjectPool objectPool
validationQuery
private String validationQuery
autoCommit
private boolean autoCommit
readOnly
private Boolean readOnly
MedJdbcDataServer.CustomPoolableConnectionFactory
public MedJdbcDataServer.CustomPoolableConnectionFactory(org.apache.commons.dbcp.ConnectionFactory connectionFactory,
org.apache.commons.pool.ObjectPool objectPool,
String validationQuery,
boolean autoCommit,
Boolean readOnly)
makeObject
public Object makeObject()
throws Exception
- Specified by:
makeObject
in interface org.apache.commons.pool.PoolableObjectFactory
- Throws:
Exception
destroyObject
public void destroyObject(Object obj)
throws Exception
- Specified by:
destroyObject
in interface org.apache.commons.pool.PoolableObjectFactory
- Throws:
Exception
validateObject
public boolean validateObject(Object obj)
- Specified by:
validateObject
in interface org.apache.commons.pool.PoolableObjectFactory
validateConnection
private boolean validateConnection(Connection conn)
throws SQLException
- Throws:
SQLException
activateObject
public void activateObject(Object obj)
throws Exception
- Specified by:
activateObject
in interface org.apache.commons.pool.PoolableObjectFactory
- Throws:
Exception
passivateObject
public void passivateObject(Object obj)
throws Exception
- Specified by:
passivateObject
in interface org.apache.commons.pool.PoolableObjectFactory
- Throws:
Exception
getAutoCommit
private boolean getAutoCommit(Connection connection)