txIsolationLevel.getCode()); dataSource = new PoolingDataSource(connectionPool);
DataSource createDataSource() { boolean connectionNoWrap = config.getBoolean(CONNECTION_NOWRAP, false); ObjectPool connectionPool = createConnectionPool(); PoolingDataSource dataSource = new PoolingDataSource(connectionPool); dataSource.setAccessToUnderlyingConnectionAllowed(connectionNoWrap); return dataSource; }
/** * Creates the actual data source instance. This method only exists so * subclasses can replace the implementation class. * * @throws SQLException if unable to create a datasource instance */ protected void createDataSourceInstance() throws SQLException { PoolingDataSource pds = new PoolingDataSource(connectionPool); pds.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed()); pds.setLogWriter(logWriter); dataSource = pds; }
poolingDataSource = new PoolingDataSource(); if ( dialect instanceof IDriverLocator ) { if ( !( (IDriverLocator) dialect ).initialize( driverClass ) ) { poolingDataSource.setPool( pool ); poolingDataSource.setAccessToUnderlyingConnectionAllowed( Boolean.parseBoolean( attributes .get( IDBDatasourceService.ACCESS_TO_UNDERLYING_CONNECTION_ALLOWED ) ) );
protected void createDataSourceInstance() throws SQLException { PoolingDataSource pds = new ManagedDataSource(connectionPool, transactionRegistry); pds.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed()); pds.setLogWriter(logWriter); dataSource = pds; }
/** * @see org.apache.commons.dbcp.DelegatingConnection#getInnermostDelegate() */ public Connection getInnermostDelegate() { if (isAccessToUnderlyingConnectionAllowed()) { return super.getInnermostDelegate(); } else { return null; } } }
@Override public Connection getConnection () throws SQLException { return this.dataSource.getConnection (); } }
/** * Creates a new {@link ConnectionPool} instance. * * @param id * @param connectURI * @param user * @param password * @param readOnly * @param minIdle * @param maxActive */ public ConnectionPool( String id, String connectURI, String user, String password, boolean readOnly, int minIdle, int maxActive ) { this.id = id; pool = new GenericObjectPool<Connection>( null ); pool.setMinIdle( minIdle ); pool.setMaxActive( maxActive ); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory( connectURI, user, password ); // TODO make this configurable new PoolableConnectionFactory( connectionFactory, pool, null, null, readOnly, true ); ds = new PoolingDataSource( pool ); // needed, so users can retrieve the underlying connection from pooled // connections, e.g. to access the // LargeObjectManager from a PGConnection ds.setAccessToUnderlyingConnectionAllowed( true ); }
/** * Creates the actual data source instance. This method only exists so * subclasses can replace the implementation class. * * @throws SQLException if unable to create a datasource instance */ protected void createDataSourceInstance() throws SQLException { PoolingDataSource pds = new PoolingDataSource(connectionPool); pds.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed()); pds.setLogWriter(logWriter); dataSource = pds; }
protected void createDataSourceInstance() throws SQLException { PoolingDataSource pds = new ManagedDataSource(connectionPool, transactionRegistry); pds.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed()); pds.setLogWriter(logWriter); dataSource = pds; }
/** * @see org.apache.commons.dbcp.DelegatingConnection#getInnermostDelegate() */ public Connection getInnermostDelegate() { if (isAccessToUnderlyingConnectionAllowed()) { return super.getInnermostDelegate(); } else { return null; } } }
@Override public Connection getConnection () throws SQLException { return this.dataSource.getConnection (); } }
return new PoolingDataSource(objectPool);
null); PoolingDataSource dataSource = new PoolingDataSource(connectionPool); dataSource.setAccessToUnderlyingConnectionAllowed(booleanProperty( properties, "accessToUnderlyingConnectionAllowed",
/** * @see org.apache.commons.dbcp.DelegatingConnection#getDelegate() */ public Connection getDelegate() { if (isAccessToUnderlyingConnectionAllowed()) { return super.getDelegate(); } else { return null; } }
/** * Returns a {@link Connection} from the pool. * * @return a connection from the pool * @throws SQLException */ public Connection getConnection() throws SQLException { LOG.debug( "For connection id '{}': active connections: {}, idle connections: {}", new Object[] { id, pool.getNumActive(), pool.getNumIdle() } ); return ds.getConnection(); }
/** * Sets up a pooling data source for connection pooling. * This can be used if the application server does not have a pooling * dataSource already configured. * * <p>This takes a normal jdbc connection string, and requires a jdbc * driver to be loaded, and then uses a * {@link DriverManagerConnectionFactory} to create connections to the * database. * * <p>An alternative method of configuring a pooling driver is to use an * external configuration file. See the the Apache jakarta-commons * commons-pool documentation. * * @param key Identifies which connection factory to use. A typical key is * a JDBC connect string, since each JDBC connect string requires a * different connection factory. * @param connectionFactory Creates connections from an underlying * JDBC connect string or DataSource * @return a pooling DataSource object */ public synchronized DataSource getPoolingDataSource( Object key, ConnectionFactory connectionFactory) { ObjectPool connectionPool = getPool(key, connectionFactory); // create pooling datasource return new PoolingDataSource(connectionPool); }
dataSource = new PoolingDataSource(connectionPool); ((PoolingDataSource) dataSource).setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed()); dataSource.setLogWriter(logWriter);
/** * @see org.apache.commons.dbcp.DelegatingConnection#getDelegate() */ public Connection getDelegate() { if (isAccessToUnderlyingConnectionAllowed()) { return super.getDelegate(); } else { return null; } }
private static DataSource setupDataSource(String uri, String user, String pass) { if (LOG.isDebugEnabled()) { StringBuilder sb = new StringBuilder("Creating database session pool: ") .append("URL: {} User: {} Password: {}"); LOG.debug(sb.toString(), new Object[]{uri, user, (pass != null && pass.trim().length() != 0) ? "****" : pass}); } ConnectionFactory cf = new DriverManagerConnectionFactory(uri, user, pass); ObjectPool pool = new GenericObjectPool(); new PoolableConnectionFactory(cf, pool, null, null, false, false); return new PoolingDataSource(pool); }