List of usage examples for javax.sql PooledConnection addConnectionEventListener
void addConnectionEventListener(ConnectionEventListener listener);
PooledConnection
object. From source file:com.alibaba.wasp.jdbcx.JdbcConnectionPool.java
private Connection getConnectionNow() throws SQLException { if (isDisposed) { throw new IllegalStateException("Connection pool has been disposed."); }//from www .j a va 2 s . c om PooledConnection pc; if (!recycledConnections.isEmpty()) { pc = recycledConnections.remove(recycledConnections.size() - 1); } else { pc = dataSource.getPooledConnection(); } Connection conn = pc.getConnection(); activeConnections.incrementAndGet(); pc.addConnectionEventListener(this); return conn; }
From source file:biz.source_code.miniConnectionPoolManager.TestMiniConnectionPoolManager.java
private synchronized Connection getConnection2() throws SQLException { if (isDisposed) throw new IllegalStateException("Connection pool has been disposed."); // test again with lock PooledConnection pconn; if (!recycledConnections.empty()) { pconn = recycledConnections.pop(); } else {//from ww w .j a v a 2s . c o m pconn = dataSource.getPooledConnection(); } Connection conn = pconn.getConnection(); activeConnections++; pconn.addConnectionEventListener(poolConnectionEventListener); assertInnerState(); return conn; }
From source file:org.enhydra.jdbc.pool.StandardPoolDataSource.java
public GenerationObject create(String _user, String _password) throws SQLException { log.debug("StandardPoolDataSource:create create a connection for the pool"); GenerationObject genObject;//from w ww.j a va 2 s . c o m PooledConnection pooledCon = cpds.getPooledConnection(_user, _password); // get the pooled connection pooledCon.addConnectionEventListener(this); // add it to the event listener log.debug("StandardPoolDataSource:create create a object for the pool"); genObject = new GenerationObject(pooledCon, pool.getGeneration(), _user, _password); return genObject; // return a connection }