use of org.apache.commons.dbcp2.ConnectionFactory in project zeppelin by apache.
the class JDBCInterpreter method createConnectionPool.
private void createConnectionPool(String url, String user, String propertyKey, Properties properties) throws SQLException, ClassNotFoundException {
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(url, properties);
PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, null);
ObjectPool connectionPool = new GenericObjectPool(poolableConnectionFactory);
poolableConnectionFactory.setPool(connectionPool);
Class.forName(properties.getProperty(DRIVER_KEY));
PoolingDriver driver = new PoolingDriver();
driver.registerPool(propertyKey + user, connectionPool);
getJDBCConfiguration(user).saveDBDriverPool(propertyKey, driver);
}
use of org.apache.commons.dbcp2.ConnectionFactory in project tomee by apache.
the class DbcpManagedDataSource method createConnectionFactory.
@Override
protected ConnectionFactory createConnectionFactory() throws SQLException {
if (ds instanceof XADataSource) {
// Create the XAConectionFactory using the XA data source
final XADataSource xaDataSourceInstance = (XADataSource) ds;
final XAConnectionFactory xaConnectionFactory = new DataSourceXAConnectionFactory(getTransactionManager(), xaDataSourceInstance, getUsername(), getPassword());
setTransactionRegistry(xaConnectionFactory.getTransactionRegistry());
return xaConnectionFactory;
}
// If xa data source is not specified a DriverConnectionFactory is created and wrapped with a LocalXAConnectionFactory
final ConnectionFactory connectionFactory = new DataSourceConnectionFactory(DataSource.class.cast(ds), getUsername(), getPassword());
final XAConnectionFactory xaConnectionFactory = new LocalXAConnectionFactory(getTransactionManager(), connectionFactory);
setTransactionRegistry(xaConnectionFactory.getTransactionRegistry());
return xaConnectionFactory;
}
Aggregations