// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.sql.*;

import org.apache.commons.dbcp.*;
import org.apache.commons.pool.impl.*;

public class PoolTrick {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        GenericObjectPool cp = new GenericObjectPool(null);
        DriverManagerConnectionFactory dmcf = new DriverManagerConnectionFactory("jdbc:mysql://localhost/Test", "", "");
        PoolableConnectionFactory pcf = new PoolableConnectionFactory(dmcf, cp, null, null, false, true);
        PoolingDataSource ds = new PoolingDataSource(cp);
        ds.setAccessToUnderlyingConnectionAllowed(true);
        Connection con = ds.getConnection();
        Connection con2 = ((DelegatingConnection) con).getInnermostDelegate();
        System.out.println(con.getClass().getName());
        System.out.println(con2.getClass().getName());
        con.close();
    }
}
