Skip to content

Instantly share code, notes, and snippets.

Avatar

Or Gerson kazabubu

View GitHub Profile
View PoolableRegisteredConnectionFactory.java
public class PoolableRegisteredConnectionFactory extends PoolableConnectionFactory {
private ConnectionRegister connectionRegister;
@Override
public Object makeObject() throws Exception {
PoolableConnection conn = (PoolableConnection) super.makeObject();
if (connectionRegister != null) {
connectionRegister.register(conn);
}
return conn;
View ClosingPoolableConnectionsDataSource.java
public class ClosingPoolableConnectionsDataSource extends BasicDataSource implements ConnectionRegister {
private Set<PoolableConnection> connections = new HashSet<>();
@Override
public synchronized void register(Connection conn) {
if (PoolableConnection.class.isAssignableFrom(conn.getClass())) {
connections.add((PoolableConnection) conn);
}
}
You can’t perform that action at this time.