1 8 package org.apache.avalon.excalibur.datasource; 9 10 import org.apache.avalon.excalibur.pool.ValidatedResourceLimitingPool; 11 12 import java.sql.SQLException ; 13 14 import org.apache.avalon.excalibur.datasource.JdbcConnection; 15 import org.apache.avalon.excalibur.pool.ObjectFactory; 16 import org.apache.avalon.excalibur.pool.Poolable; 17 18 30 public class ResourceLimitingJdbcConnectionPool 31 extends ValidatedResourceLimitingPool 32 { 33 private boolean m_autoCommit; 34 35 38 56 public ResourceLimitingJdbcConnectionPool( final ObjectFactory factory, 57 int max, 58 boolean maxStrict, 59 boolean blocking, 60 long blockTimeout, 61 long trimInterval, 62 boolean autoCommit ) 63 { 64 65 super(factory, max, maxStrict, blocking, blockTimeout, trimInterval); 66 67 m_autoCommit = autoCommit; 68 } 69 70 73 80 protected Poolable newPoolable() throws Exception { 81 JdbcConnection conn = (JdbcConnection)super.newPoolable(); 82 83 conn.setPool(this); 85 86 conn.setAutoCommit(m_autoCommit); 88 89 return conn; 90 } 91 92 101 protected boolean validatePoolable(Poolable poolable) { 102 JdbcConnection conn = (JdbcConnection)poolable; 103 try { 104 if (conn.isClosed()) { 109 getLogger().debug("JdbcConnection was closed."); 110 return false; 111 } 112 } catch (SQLException e) { 113 getLogger().debug( 114 "Failed to check whether JdbcConnection was closed. " + e.getMessage()); 115 } 116 117 return true; 118 } 119 120 123 124 127 } 128 129 | Popular Tags |