List of usage examples for org.apache.commons.dbcp DataSourceConnectionFactory DataSourceConnectionFactory
public DataSourceConnectionFactory(DataSource source, String uname, String passwd)
From source file:mondrian.rolap.RolapConnectionPool.java
public synchronized DataSource getDataSourcePoolingDataSource(DataSource dataSource, String dataSourceName, String jdbcUser, String jdbcPassword) { // First look for a data source with identical specification. This in // turn helps us to use the cache of Dialect objects. List<Object> key = Arrays.asList("DataSourcePoolingDataSource", dataSource, jdbcUser, jdbcPassword); DataSource pooledDataSource = dataSourceMap.get(key); if (pooledDataSource != null) { return pooledDataSource; }/* ww w. j av a 2 s. c om*/ ConnectionFactory connectionFactory; if (jdbcUser != null || jdbcPassword != null) { connectionFactory = new DataSourceConnectionFactory(dataSource, jdbcUser, jdbcPassword); } else { connectionFactory = new DataSourceConnectionFactory(dataSource); } try { pooledDataSource = getPoolingDataSource(dataSourceName, connectionFactory); } catch (Exception e) { throw Util.newInternal(e, "Error while creating connection pool (with URI " + dataSourceName + ")"); } dataSourceMap.put(key, pooledDataSource); return dataSource; }
From source file:org.apache.openejb.resource.jdbc.dbcp.BasicDataSource.java
@Override protected ConnectionFactory createConnectionFactory() throws SQLException { if (delegate != null) { if (XADataSource.class.isInstance(delegate)) { return new DataSourceXAConnectionFactory(OpenEJB.getTransactionManager(), XADataSource.class.cast(delegate), username, password); }//from ww w. j a v a 2s . c o m return new DataSourceConnectionFactory(DataSource.class.cast(delegate), username, password); } return super.createConnectionFactory(); }
From source file:org.apache.openejb.resource.jdbc.dbcp.DbcpDataSource.java
@Override protected ConnectionFactory createConnectionFactory() throws SQLException { return new DataSourceConnectionFactory(this.ds, username, password); }
From source file:org.apache.openejb.resource.jdbc.dbcp.DbcpManagedDataSource.java
@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, username, password); setTransactionRegistry(xaConnectionFactory.getTransactionRegistry()); return xaConnectionFactory; }// w w w . j a v a2 s .co m // 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), username, password); final XAConnectionFactory xaConnectionFactory = new LocalXAConnectionFactory(getTransactionManager(), connectionFactory); setTransactionRegistry(xaConnectionFactory.getTransactionRegistry()); return xaConnectionFactory; }