net.sf.farrago.namespace.jdbc
Class MedJdbcDataServer.CustomPoolableConnectionFactory

java.lang.Object
  extended by 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.


Field Summary
private  boolean autoCommit
           
private  org.apache.commons.dbcp.ConnectionFactory connectionFactory
           
private  org.apache.commons.pool.ObjectPool objectPool
           
private  Boolean readOnly
           
private  String validationQuery
           
 
Constructor Summary
MedJdbcDataServer.CustomPoolableConnectionFactory(org.apache.commons.dbcp.ConnectionFactory connectionFactory, org.apache.commons.pool.ObjectPool objectPool, String validationQuery, boolean autoCommit, Boolean readOnly)
           
 
Method Summary
 void activateObject(Object obj)
           
 void destroyObject(Object obj)
           
private  boolean getAutoCommit(Connection connection)
           
 Object makeObject()
           
 void passivateObject(Object obj)
           
private  boolean validateConnection(Connection conn)
           
 boolean validateObject(Object obj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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
Constructor Detail

MedJdbcDataServer.CustomPoolableConnectionFactory

public MedJdbcDataServer.CustomPoolableConnectionFactory(org.apache.commons.dbcp.ConnectionFactory connectionFactory,
                                                         org.apache.commons.pool.ObjectPool objectPool,
                                                         String validationQuery,
                                                         boolean autoCommit,
                                                         Boolean readOnly)
Method Detail

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)