I am attempting to configure a UCP PoolDataSourceImpl with a ConnectionInitializationCallback. Here's my configuration:
private static DataSource createDataSource(Properties properties) throws SQLException, UniversalConnectionPoolException {
UniversalConnectionPoolManager ucpm = UniversalConnectionPoolManagerImpl.getUniversalConnectionPoolManager();
PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource();
final String editionName = properties.getProperty("jdbc.editionName", "ora$base");
pds.registerConnectionInitializationCallback(new oracle.ucp.jdbc.ConnectionInitializationCallback() {
public void initialize(Connection connection) throws SQLException {
LOG.debug("Attempting to set edition to: {}", editionName);
try (Statement statement = connection.createStatement()) {
statement.executeUpdate("ALTER SESSION SET EDITION = " + editionName);
}
LOG.debug("Edition set to: {}", editionName);
}
});
pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
pds.setUser(properties.getProperty("jdbc.username"));
pds.setPassword(properties.getProperty("jdbc.password"));
pds.setURL(properties.getProperty("jdbc.url"));
pds.setConnectionPoolName("demo-pool");
pds.setInitialPoolSize(3);
pds.setMaxPoolSize(3);
pds.setValidateConnectionOnBorrow(true);
LOG.debug("Created DataSource Pool");
ucpm.createConnectionPool((UniversalConnectionPoolAdapter)pds);
ucpm.startConnectionPool("demo-pool");
return pds;
}
However the initialize method is never called. I'm using java 1.7.0_51 with the following Oracle jars:
Any help with getting the ConnectionInitializationCallback to work would be much appreciated.