org.apache.commons.pool.ObjectPool Java Examples

The following examples show how to use org.apache.commons.pool.ObjectPool. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeyedResourcePool.java    From JVoiceXML with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns a previously borrowed resource to the pool.
 * @param key resource type.
 * @param resource resource to return.
 * @throws NoresourceError
 *         Error returning the object to the pool.
 * @since 0.6
 */
public synchronized void returnObject(final String key,
        final T resource) throws NoresourceError {
    final ObjectPool<T> pool = pools.get(key);
    if (pool == null) {
        throw new NoresourceError("Pool of type '" + key + "' is unknown!");
    }
    try {
        pool.returnObject(resource);
    } catch (Exception e) {
        throw new NoresourceError(e.getMessage(), e);
    }
    LOGGER.info("returned object of type '" + key + "' ("
            + resource.getClass().getCanonicalName() + ")");

    if (LOGGER.isDebugEnabled()) {
        final int active = pool.getNumActive();
        final int idle = pool.getNumIdle();
        LOGGER.debug("pool has now " + active
                     + " active/" + idle + " idle for key '" + key
                     + "' (" + resource.getClass().getCanonicalName()
                     + ") after return");
    }
}
 
Example #2
Source File: DBase.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public DataSource newDataSource (String driver, String connect, String login, String password) {
	ObjectPool <Object>		connectionPool = new GenericObjectPool<>(null, dsPoolsize, (dsPoolgrow ? GenericObjectPool.WHEN_EXHAUSTED_GROW : GenericObjectPool.WHEN_EXHAUSTED_BLOCK), 0);
	ConnectionFactory		connectionFactory = new DriverManagerConnectionFactory (connect, login, password);

	// THIS IS REQUIRED DUE TO INTERNAL SIDE EFFECTS, DO NOT REMOVE THIS (AGAIN)!
	@SuppressWarnings("unused")
	PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory (connectionFactory, connectionPool, null, null, false, true);
	log.out (Log.INFO, "nds", "New data source for " + driver + " using " + connect + " with " + login + " created (poolsize " + dsPoolsize + ", grow is " + dsPoolgrow + ")");
	return new PoolingDataSource (connectionPool);
}
 
Example #3
Source File: CommonsPoolTargetSource.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Subclasses can override this if they want to return a specific Commons pool.
 * They should apply any configuration properties to the pool here.
 * <p>Default is a GenericObjectPool instance with the given pool size.
 * @return an empty Commons {@code ObjectPool}.
 * @see org.apache.commons.pool.impl.GenericObjectPool
 * @see #setMaxSize
 */
protected ObjectPool createObjectPool() {
	GenericObjectPool gop = new GenericObjectPool(this);
	gop.setMaxActive(getMaxSize());
	gop.setMaxIdle(getMaxIdle());
	gop.setMinIdle(getMinIdle());
	gop.setMaxWait(getMaxWait());
	gop.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
	gop.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
	gop.setWhenExhaustedAction(getWhenExhaustedAction());
	return gop;
}
 
Example #4
Source File: DataSourceProviderDbcpImpl.java    From ralasafe with MIT License 5 votes vote down vote up
public void setup( Properties prop ) {
	this.prop=prop;

       GenericObjectPool.Config conPoolCfg = new GenericObjectPool.Config();
       conPoolCfg.maxActive = Integer.parseInt( prop.getProperty( "connectionPoolMaxSize", "15" ) );
       conPoolCfg.maxIdle = Integer.parseInt( prop.getProperty( "connectionPoolMaxIdle", "8" ) );
       conPoolCfg.maxWait = Integer.parseInt( prop.getProperty( "connectionPoolMaxWait", "60000" ) );
       conPoolCfg.minIdle = Integer.parseInt( prop.getProperty( "connectionPoolMinSize", "2" ) );


       ObjectPool connectionPool = new GenericObjectPool( null, conPoolCfg );
       try {
		Class.forName( prop.getProperty( "jdbcDriver" ) );
	} catch( ClassNotFoundException e ) {
		e.printStackTrace();
		throw new RuntimeException();
	}

       ConnectionFactory connectionFactory = new
           DriverManagerConnectionFactory( prop.getProperty( "jdbcUrl" ),
                                          prop.getProperty( "jdbcUser" ), 
                                          prop.getProperty( "jdbcPassword" ) );


       new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true);

       PoolingDataSource dataSource = new PoolingDataSource(connectionPool);
       
       ds = dataSource;
}
 
Example #5
Source File: ElexisPoolingDataSource.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private ObjectPool<Connection> createConnectionPool(DBConnection dbConnection)
	throws InstantiationException, IllegalAccessException, ClassNotFoundException{
	String driverName = StringUtils.defaultString(dbConnection.rdbmsType.driverName);
	String username = StringUtils.defaultString(dbConnection.username);
	String password = StringUtils.defaultString(dbConnection.password);
	String jdbcString = StringUtils.defaultString(dbConnection.connectionString);
	
	Driver driver = (Driver) Class.forName(driverName).newInstance();
	
	Properties properties = new Properties();
	properties.put("user", username);
	properties.put("password", password);
	
	log.info("db connection pool [" + driver + ", " + jdbcString + ", " + username
		+ "] initialization");
	
	ConnectionFactory connectionFactory =
		new DriverConnectionFactory(driver, jdbcString, properties);
	
	GenericObjectPool<Connection> connectionPool = new GenericObjectPool<>(null);
	connectionPool.setMaxActive(32);
	connectionPool.setMinIdle(8);
	connectionPool.setMaxWait(10000);
	connectionPool.setTestOnBorrow(true);
	
	new PoolableConnectionFactory(connectionFactory, connectionPool, null, "SELECT 1;", false,
		true);
	return connectionPool;
	
}
 
Example #6
Source File: KeyedResourcePool.java    From JVoiceXML with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Retrieves the number of active resources in all pools.
 * @return number of active resources
 * @since 0.7.3
 */
public synchronized int getNumActive() {
    int active = 0;
    final Collection<ObjectPool<T>> col = pools.values();
    for (ObjectPool<T> pool : col) {
        active += pool.getNumActive();
    }
    return active;
}
 
Example #7
Source File: KeyedResourcePool.java    From JVoiceXML with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Retrieves the number of idle resources in all pools.
 * @return number of idle resources
 * @since 0.7.3
 */
public synchronized int getNumIdle() {
    int idle = 0;
    final Collection<ObjectPool<T>> col = pools.values();
    for (ObjectPool<T> pool : col) {
        idle += pool.getNumIdle();
    }
    return idle;
}
 
Example #8
Source File: KeyedResourcePool.java    From JVoiceXML with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Retrieves the number of idle resources in the pool for the given key.
 * @param key the key
 * @return number of idle resources, <code>-1</code> if there is no resource
 *         with that key
 * @since 0.7.3
 */
public synchronized int getNumIdle(final String key) {
    final ObjectPool<T> pool = pools.get(key);
    if (pool == null) {
        return -1;
    }
    return pool.getNumIdle();
}
 
Example #9
Source File: KeyedResourcePool.java    From JVoiceXML with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Closes all pools for all keys.
 * @throws Exception
 *         error closing a pool
 * @since 0.7.3
 */
public synchronized void close() throws Exception {
    final Collection<ObjectPool<T>> col = pools.values();
    for (ObjectPool<T> pool : col) {
        pool.close();
    }
}
 
Example #10
Source File: DB.java    From jelectrum with MIT License 5 votes vote down vote up
public static void printDriverStats(String pool_name) throws Exception
{
    PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
    ObjectPool connectionPool = driver.getConnectionPool(pool_name);
    System.out.println("NumActive: " + connectionPool.getNumActive());
    System.out.println("NumIdle: " + connectionPool.getNumIdle());
}
 
Example #11
Source File: RaftClient.java    From TakinRPC with Apache License 2.0 4 votes vote down vote up
RaftClient(@Nonnull ObjectPool<NettyRpcChannel> channelPool) {
    this.channelPool = checkNotNull(channelPool);
}
 
Example #12
Source File: ProtoRpcRaftClient.java    From barge with Apache License 2.0 4 votes vote down vote up
ProtoRpcRaftClient(@Nonnull ObjectPool<CompletableFuture<NettyRpcChannel>> channelPool) {
  this.channelPool = checkNotNull(channelPool);
}
 
Example #13
Source File: DBCPConnectionFactory.java    From ontopia with Apache License 2.0 4 votes vote down vote up
TraceablePoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit) {
  super(connFactory, pool, stmtPoolFactory, validationQuery, defaultReadOnly, defaultAutoCommit);
}
 
Example #14
Source File: KeyedResourcePool.java    From JVoiceXML with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Constructs a new object.
 */
public KeyedResourcePool() {
    super();
    pools = new java.util.HashMap<String, ObjectPool<T>>();
}
 
Example #15
Source File: SakaiPoolableConnectionFactory.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Create a new <tt>PoolableConnectionFactory</tt>.
 * 
 * @param connFactory
 *        the {@link ConnectionFactory} from which to obtain base {@link Connection}s
 * @param pool
 *        the {@link ObjectPool} in which to pool those {@link Connection}s
 * @param stmtPoolFactory
 *        the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
 * @param validationQuery
 *        a query to use to {@link #validateObject validate} {@link Connection}s. Should return at least one row. Using <tt>null</tt> turns off validation.
 * @param defaultReadOnly
 *        the default "read only" setting for borrowed {@link Connection}s
 * @param defaultAutoCommit
 *        the default "auto commit" setting for returned {@link Connection}s
 * @param defaultTransactionIsolation
 *        the default "Transaction Isolation" setting for returned {@link Connection}s
 * @param rollbackOnReturn
 *        The rollback on borrow setting
 */
public SakaiPoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory,
		String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation,
		boolean rollbackOnReturn)
{
	super(connFactory, pool, stmtPoolFactory, validationQuery, defaultReadOnly, defaultAutoCommit, defaultTransactionIsolation);
	m_rollbackOnReturn = rollbackOnReturn;
}
 
Example #16
Source File: GenericSyslogPoolFactory.java    From syslog4j-graylog2 with GNU Lesser General Public License v2.1 3 votes vote down vote up
public ObjectPool createPool() throws SyslogRuntimeException {
    GenericObjectPool genericPool = new GenericObjectPool(this);

    configureGenericObjectPool(genericPool);

    return genericPool;
}
 
Example #17
Source File: GenericSyslogPoolFactory.java    From syslog4j with GNU Lesser General Public License v2.1 3 votes vote down vote up
public ObjectPool createPool() throws SyslogRuntimeException {
	GenericObjectPool genericPool = new GenericObjectPool(this);
	
	configureGenericObjectPool(genericPool);
	
	return genericPool;
}
 
Example #18
Source File: SakaiPoolableConnectionFactory.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Create a new <tt>PoolableConnectionFactory</tt>.
 * 
 * @param connFactory
 *        the {@link ConnectionFactory} from which to obtain base {@link Connection}s
 * @param pool
 *        the {@link ObjectPool} in which to pool those {@link Connection}s
 * @param stmtPoolFactory
 *        the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
 * @param validationQuery
 *        a query to use to {@link #validateObject validate} {@link Connection}s. Should return at least one row. Using <tt>null</tt> turns off validation.
 * @param defaultReadOnly
 *        the default "read only" setting for borrowed {@link Connection}s
 * @param defaultAutoCommit
 *        the default "auto commit" setting for returned {@link Connection}s
 * @param defaultTransactionIsolation
 *        the default "Transaction Isolation" setting for returned {@link Connection}s
 * @param defaultCatalog
 *        the default "catalog" setting for returned {@link Connection}s
 * @param config
 *        the AbandonedConfig if tracing SQL objects
 * @param rollbackOnReturn
 *        The rollback on borrow setting
 */
public SakaiPoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory,
		String validationQuery, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation,
		String defaultCatalog, AbandonedConfig config, boolean rollbackOnReturn)
{
	super(connFactory, pool, stmtPoolFactory, validationQuery, defaultReadOnly, defaultAutoCommit, defaultTransactionIsolation,
			defaultCatalog, config);
	m_rollbackOnReturn = rollbackOnReturn;
}
 
Example #19
Source File: SakaiPoolableConnectionFactory.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Create a new <tt>PoolableConnectionFactory</tt>.
 * 
 * @param connFactory
 *        the {@link ConnectionFactory} from which to obtain base {@link Connection}s
 * @param pool
 *        the {@link ObjectPool} in which to pool those {@link Connection}s
 * @param stmtPoolFactory
 *        the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
 * @param validationQuery
 *        a query to use to {@link #validateObject validate} {@link Connection}s. Should return at least one row. Using <tt>null</tt> turns off validation.
 * @param defaultReadOnly
 *        the default "read only" setting for borrowed {@link Connection}s
 * @param defaultAutoCommit
 *        the default "auto commit" setting for returned {@link Connection}s
 * @param defaultTransactionIsolation
 *        the default "Transaction Isolation" setting for returned {@link Connection}s
 * @param defaultCatalog
 *        the default "catalog" setting for returned {@link Connection}s
 * @param config
 *        the AbandonedConfig if tracing SQL objects
 * @param rollbackOnReturn
 *        The rollback on borrow setting
 * @deprecated AbandonedConfig is now deprecated.
 */
public SakaiPoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory,
		String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation,
		String defaultCatalog, AbandonedConfig config, boolean rollbackOnReturn)
{
	super(connFactory, pool, stmtPoolFactory, validationQuery, defaultReadOnly, defaultAutoCommit, defaultTransactionIsolation,
			defaultCatalog, config);
	m_rollbackOnReturn = rollbackOnReturn;
}
 
Example #20
Source File: SakaiPoolableConnectionFactory.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Create a new <tt>PoolableConnectionFactory</tt>.
 * 
 * @param connFactory
 *        the {@link ConnectionFactory} from which to obtain base {@link Connection}s
 * @param pool
 *        the {@link ObjectPool} in which to pool those {@link Connection}s
 * @param stmtPoolFactory
 *        the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
 * @param validationQuery
 *        a query to use to {@link #validateObject validate} {@link Connection}s. Should return at least one row. Using <tt>null</tt> turns off validation.
 * @param defaultReadOnly
 *        the default "read only" setting for borrowed {@link Connection}s
 * @param defaultAutoCommit
 *        the default "auto commit" setting for returned {@link Connection}s
 * @param defaultTransactionIsolation
 *        the default "Transaction Isolation" setting for returned {@link Connection}s
 * @param config
 *        the AbandonedConfig if tracing SQL objects
 * @param rollbackOnReturn
 *        The rollback on borrow setting
 * @deprecated AbandonedConfig is now deprecated.
 */
public SakaiPoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory,
		String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation,
		AbandonedConfig config, boolean rollbackOnReturn)
{
	super(connFactory, pool, stmtPoolFactory, validationQuery, defaultReadOnly, defaultAutoCommit, defaultTransactionIsolation,
			config);
	m_rollbackOnReturn = rollbackOnReturn;
}
 
Example #21
Source File: SakaiPoolableConnectionFactory.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Create a new <tt>PoolableConnectionFactory</tt>.
 * 
 * @param connFactory
 *        the {@link ConnectionFactory} from which to obtain base {@link Connection}s
 * @param pool
 *        the {@link ObjectPool} in which to pool those {@link Connection}s
 * @param stmtPoolFactory
 *        the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
 * @param validationQuery
 *        a query to use to {@link #validateObject validate} {@link Connection}s. Should return at least one row. Using <tt>null</tt> turns off validation.
 * @param defaultReadOnly
 *        the default "read only" setting for borrowed {@link Connection}s
 * @param defaultAutoCommit
 *        the default "auto commit" setting for returned {@link Connection}s
 * @param config
 *        the AbandonedConfig if tracing SQL objects
 * @param rollbackOnReturn
 *        The rollback on borrow setting
 * @deprecated AbandonedConfig is now deprecated.
 */
public SakaiPoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory,
		String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, AbandonedConfig config,
		boolean rollbackOnReturn)
{
	super(connFactory, pool, stmtPoolFactory, validationQuery, defaultReadOnly, defaultAutoCommit, config);
	m_rollbackOnReturn = rollbackOnReturn;
}
 
Example #22
Source File: SakaiPoolableConnectionFactory.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Create a new <tt>PoolableConnectionFactory</tt>.
 * 
 * @param connFactory
 *        the {@link ConnectionFactory} from which to obtain base {@link Connection}s
 * @param pool
 *        the {@link ObjectPool} in which to pool those {@link Connection}s
 * @param stmtPoolFactory
 *        the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
 * @param validationQuery
 *        a query to use to {@link #validateObject validate} {@link Connection}s. Should return at least one row. Using <tt>null</tt> turns off validation.
 * @param defaultReadOnly
 *        the default "read only" setting for borrowed {@link Connection}s
 * @param defaultAutoCommit
 *        the default "auto commit" setting for returned {@link Connection}s
 * @param rollbackOnReturn
 *        The rollback on borrow setting
 */
public SakaiPoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory,
		String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, boolean rollbackOnReturn)
{
	super(connFactory, pool, stmtPoolFactory, validationQuery, defaultReadOnly, defaultAutoCommit);
	m_rollbackOnReturn = rollbackOnReturn;
}
 
Example #23
Source File: SakaiPoolableConnectionFactory.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Create a new <tt>PoolableConnectionFactory</tt>.
 * 
 * @param connFactory
 *        the {@link ConnectionFactory} from which to obtain base {@link Connection}s
 * @param pool
 *        the {@link ObjectPool} in which to pool those {@link Connection}s
 * @param stmtPoolFactory
 *        the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
 * @param validationQuery
 *        a query to use to {@link #validateObject validate} {@link Connection}s. Should return at least one row. Using <tt>null</tt> turns off validation.
 * @param defaultReadOnly
 *        the default "read only" setting for borrowed {@link Connection}s
 * @param defaultAutoCommit
 *        the default "auto commit" setting for returned {@link Connection}s
 * @param rollbackOnReturn
 *        The rollback on borrow setting
 */
public SakaiPoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory,
		String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, boolean rollbackOnReturn)
{
	super(connFactory, pool, stmtPoolFactory, validationQuery, defaultReadOnly, defaultAutoCommit);
	m_rollbackOnReturn = rollbackOnReturn;
}
 
Example #24
Source File: SakaiPoolableConnectionFactory.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Create a new <tt>PoolableConnectionFactory</tt>.
 * 
 * @param connFactory
 *        the {@link ConnectionFactory} from which to obtain base {@link Connection}s
 * @param pool
 *        the {@link ObjectPool} in which to pool those {@link Connection}s
 * @param stmtPoolFactory
 *        the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
 * @param validationQuery
 *        a query to use to {@link #validateObject validate} {@link Connection}s. Should return at least one row. Using <tt>null</tt> turns off validation.
 * @param defaultReadOnly
 *        the default "read only" setting for borrowed {@link Connection}s
 * @param defaultAutoCommit
 *        the default "auto commit" setting for returned {@link Connection}s
 * @param defaultTransactionIsolation
 *        the default "Transaction Isolation" setting for returned {@link Connection}s
 * @param defaultCatalog
 *        the default "catalog" setting for returned {@link Connection}s
 * @param config
 *        the AbandonedConfig if tracing SQL objects
 * @param rollbackOnReturn
 *        The rollback on borrow setting
 */
public SakaiPoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory,
		String validationQuery, Boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation,
		String defaultCatalog, AbandonedConfig config, boolean rollbackOnReturn)
{
	super(connFactory, pool, stmtPoolFactory, validationQuery, defaultReadOnly, defaultAutoCommit, defaultTransactionIsolation,
			defaultCatalog, config);
	m_rollbackOnReturn = rollbackOnReturn;
}
 
Example #25
Source File: SakaiPoolableConnectionFactory.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Create a new <tt>PoolableConnectionFactory</tt>.
 * 
 * @param connFactory
 *        the {@link ConnectionFactory} from which to obtain base {@link Connection}s
 * @param pool
 *        the {@link ObjectPool} in which to pool those {@link Connection}s
 * @param stmtPoolFactory
 *        the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
 * @param validationQuery
 *        a query to use to {@link #validateObject validate} {@link Connection}s. Should return at least one row. Using <tt>null</tt> turns off validation.
 * @param defaultReadOnly
 *        the default "read only" setting for borrowed {@link Connection}s
 * @param defaultAutoCommit
 *        the default "auto commit" setting for returned {@link Connection}s
 * @param defaultTransactionIsolation
 *        the default "Transaction Isolation" setting for returned {@link Connection}s
 * @param defaultCatalog
 *        the default "catalog" setting for returned {@link Connection}s
 * @param config
 *        the AbandonedConfig if tracing SQL objects
 * @param rollbackOnReturn
 *        The rollback on borrow setting
 * @deprecated AbandonedConfig is now deprecated.
 */
public SakaiPoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory,
		String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation,
		String defaultCatalog, AbandonedConfig config, boolean rollbackOnReturn)
{
	super(connFactory, pool, stmtPoolFactory, validationQuery, defaultReadOnly, defaultAutoCommit, defaultTransactionIsolation,
			defaultCatalog, config);
	m_rollbackOnReturn = rollbackOnReturn;
}
 
Example #26
Source File: SakaiPoolableConnectionFactory.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Create a new <tt>PoolableConnectionFactory</tt>.
 * 
 * @param connFactory
 *        the {@link ConnectionFactory} from which to obtain base {@link Connection}s
 * @param pool
 *        the {@link ObjectPool} in which to pool those {@link Connection}s
 * @param stmtPoolFactory
 *        the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
 * @param validationQuery
 *        a query to use to {@link #validateObject validate} {@link Connection}s. Should return at least one row. Using <tt>null</tt> turns off validation.
 * @param defaultReadOnly
 *        the default "read only" setting for borrowed {@link Connection}s
 * @param defaultAutoCommit
 *        the default "auto commit" setting for returned {@link Connection}s
 * @param defaultTransactionIsolation
 *        the default "Transaction Isolation" setting for returned {@link Connection}s
 * @param config
 *        the AbandonedConfig if tracing SQL objects
 * @param rollbackOnReturn
 *        The rollback on borrow setting
 * @deprecated AbandonedConfig is now deprecated.
 */
public SakaiPoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory,
		String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation,
		AbandonedConfig config, boolean rollbackOnReturn)
{
	super(connFactory, pool, stmtPoolFactory, validationQuery, defaultReadOnly, defaultAutoCommit, defaultTransactionIsolation,
			config);
	m_rollbackOnReturn = rollbackOnReturn;
}
 
Example #27
Source File: SakaiPoolableConnectionFactory.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Create a new <tt>PoolableConnectionFactory</tt>.
 * 
 * @param connFactory
 *        the {@link ConnectionFactory} from which to obtain base {@link Connection}s
 * @param pool
 *        the {@link ObjectPool} in which to pool those {@link Connection}s
 * @param stmtPoolFactory
 *        the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
 * @param validationQuery
 *        a query to use to {@link #validateObject validate} {@link Connection}s. Should return at least one row. Using <tt>null</tt> turns off validation.
 * @param defaultReadOnly
 *        the default "read only" setting for borrowed {@link Connection}s
 * @param defaultAutoCommit
 *        the default "auto commit" setting for returned {@link Connection}s
 * @param config
 *        the AbandonedConfig if tracing SQL objects
 * @param rollbackOnReturn
 *        The rollback on borrow setting
 * @deprecated AbandonedConfig is now deprecated.
 */
public SakaiPoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory,
		String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, AbandonedConfig config,
		boolean rollbackOnReturn)
{
	super(connFactory, pool, stmtPoolFactory, validationQuery, defaultReadOnly, defaultAutoCommit, config);
	m_rollbackOnReturn = rollbackOnReturn;
}
 
Example #28
Source File: SakaiPoolableConnectionFactory.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Create a new <tt>PoolableConnectionFactory</tt>.
 * 
 * @param connFactory
 *        the {@link ConnectionFactory} from which to obtain base {@link Connection}s
 * @param pool
 *        the {@link ObjectPool} in which to pool those {@link Connection}s
 * @param stmtPoolFactory
 *        the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
 * @param validationQuery
 *        a query to use to {@link #validateObject validate} {@link Connection}s. Should return at least one row. Using <tt>null</tt> turns off validation.
 * @param defaultReadOnly
 *        the default "read only" setting for borrowed {@link Connection}s
 * @param defaultAutoCommit
 *        the default "auto commit" setting for returned {@link Connection}s
 * @param defaultTransactionIsolation
 *        the default "Transaction Isolation" setting for returned {@link Connection}s
 * @param rollbackOnReturn
 *        The rollback on borrow setting
 */
public SakaiPoolableConnectionFactory(ConnectionFactory connFactory, ObjectPool pool, KeyedObjectPoolFactory stmtPoolFactory,
		String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation,
		boolean rollbackOnReturn)
{
	super(connFactory, pool, stmtPoolFactory, validationQuery, defaultReadOnly, defaultAutoCommit, defaultTransactionIsolation);
	m_rollbackOnReturn = rollbackOnReturn;
}
 
Example #29
Source File: MockedDbcpPoolingConnection.java    From liquibase-percona with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a mocked SQL connection, that looks like a apache commons dbcp pooled connection.
 * @param username the username to use
 * @param password the password to use
 * @return the connection
 * @throws SQLException
 */
public static Connection create(String username, String password) throws SQLException {
    ObjectPool pool = new MockedObjectPool(username, password);
    PoolingDataSource ds = new PoolingDataSource(pool);
    return ds.getConnection();
}
 
Example #30
Source File: KeyedResourcePool.java    From JVoiceXML with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Retrieves the number of active resources in the pool for the given key.
 * @param key the key
 * @return number of active resources
 * @since 0.7.3
 */
public synchronized int getNumActive(final String key) {
    final ObjectPool<T> pool = pools.get(key);
    return pool.getNumActive();
}