Code example for PooledConnection

Methods: addConnectionEventListener

0
            throw new IllegalStateException("Connection pool data source returned null from getPooledConnection");
        } 
 
        // should we add this object as a listener or the pool. 
        // consider the validateObject method in decision 
        pc.addConnectionEventListener(this);
        pci = new PooledConnectionAndInfo(pc, username, password);
        pcMap.put(pc, pci);
 
        return new DefaultPooledObject<>(pci);
    } 
 
    /** 
     * Closes the PooledConnection and stops listening for events from it. 
     */ 
    @Override 
    public void destroyObject(UserPassKey key, PooledObject<PooledConnectionAndInfo> p)
            throws Exception { 
        PooledConnection pc = p.getObject().getPooledConnection();
        pc.removeConnectionEventListener(this);