Search in sources :

Example 11 with BoneCPDataSource

use of com.jolbox.bonecp.BoneCPDataSource in project druid by alibaba.

the class Case0 method f_test_2.

public void f_test_2() throws Exception {
    BoneCPDataSource dataSource = new BoneCPDataSource();
    // dataSource.(10);
    // dataSource.setMaxActive(50);
    dataSource.setMinConnectionsPerPartition(minIdle);
    dataSource.setMaxConnectionsPerPartition(maxIdle);
    dataSource.setDriverClass(driverClass);
    dataSource.setJdbcUrl(jdbcUrl);
    // dataSource.setPoolPreparedStatements(true);
    // dataSource.setMaxOpenPreparedStatements(100);
    dataSource.setUsername(user);
    dataSource.setPassword(password);
    dataSource.setConnectionTestStatement(validationQuery);
    dataSource.setPartitionCount(1);
    for (int i = 0; i < LOOP_COUNT; ++i) {
        p0(dataSource, "boneCP");
    }
    System.out.println();
}
Also used : BoneCPDataSource(com.jolbox.bonecp.BoneCPDataSource)

Example 12 with BoneCPDataSource

use of com.jolbox.bonecp.BoneCPDataSource in project druid by alibaba.

the class Oracle_Case0 method test_2.

public void test_2() throws Exception {
    BoneCPDataSource dataSource = new BoneCPDataSource();
    // dataSource.(10);
    // dataSource.setMaxActive(50);
    dataSource.setMinConnectionsPerPartition(minPoolSize);
    dataSource.setMaxConnectionsPerPartition(maxPoolSize);
    dataSource.setDriverClass(driverClass);
    dataSource.setJdbcUrl(jdbcUrl);
    // dataSource.setPoolPreparedStatements(true);
    // dataSource.setMaxOpenPreparedStatements(100);
    dataSource.setUsername(user);
    dataSource.setPassword(password);
    dataSource.setConnectionTestStatement(validationQuery);
    dataSource.setPartitionCount(1);
    for (int i = 0; i < LOOP_COUNT; ++i) {
        p0(dataSource, "boneCP");
    }
    System.out.println();
}
Also used : BoneCPDataSource(com.jolbox.bonecp.BoneCPDataSource)

Example 13 with BoneCPDataSource

use of com.jolbox.bonecp.BoneCPDataSource in project druid by alibaba.

the class TestLRU method f_test_boneCP.

public void f_test_boneCP() throws Exception {
    BoneCPDataSource ds = new BoneCPDataSource();
    ds.setJdbcUrl("jdbc:mock:test");
    ds.setPartitionCount(1);
    ds.setMaxConnectionsPerPartition(10);
    ds.setMinConnectionsPerPartition(0);
    for (int i = 0; i < 10; ++i) {
        f(ds, 5);
        System.out.println("--------------------------------------------");
    }
}
Also used : BoneCPDataSource(com.jolbox.bonecp.BoneCPDataSource)

Example 14 with BoneCPDataSource

use of com.jolbox.bonecp.BoneCPDataSource in project tomee by apache.

the class BoneCPDataSourceCreator method pool.

@Override
public CommonDataSource pool(final String name, final String driver, final Properties properties) {
    final BoneCPDataSource pool = createPool(properties);
    if (pool.getDriverClass() == null) {
        pool.setDriverClass(driver);
    }
    if (pool.getPoolName() == null) {
        pool.setPoolName(name);
    }
    final String xa = String.class.cast(properties.remove("XaDataSource"));
    if (xa != null) {
        final XADataSource xaDs = XADataSourceResource.proxy(Thread.currentThread().getContextClassLoader(), xa);
        pool.setDatasourceBean(new ManagedXADataSource(xaDs, OpenEJB.getTransactionManager(), SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class)));
    }
    return pool;
}
Also used : XADataSource(javax.sql.XADataSource) ManagedXADataSource(org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource) ManagedXADataSource(org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource) BoneCPDataSource(com.jolbox.bonecp.BoneCPDataSource)

Example 15 with BoneCPDataSource

use of com.jolbox.bonecp.BoneCPDataSource in project tomee by apache.

the class BoneCPDataSourceCreator method createPool.

private BoneCPDataSource createPool(final Properties properties) {
    final BoneCPConfig config;
    try {
        config = new BoneCPConfig(prefixedProps(properties));
    } catch (Exception e) {
        throw new IllegalArgumentException(e);
    }
    final BoneCPDataSource dataSourceProvidedPool = new BoneCPDataSource(config);
    // no error
    recipes.put(dataSourceProvidedPool, new ObjectRecipe(BoneCPDataSource.class.getName()));
    return dataSourceProvidedPool;
}
Also used : ObjectRecipe(org.apache.xbean.recipe.ObjectRecipe) BoneCPConfig(com.jolbox.bonecp.BoneCPConfig) BoneCPDataSource(com.jolbox.bonecp.BoneCPDataSource) SQLException(java.sql.SQLException)

Aggregations

BoneCPDataSource (com.jolbox.bonecp.BoneCPDataSource)15 BoneCPConfig (com.jolbox.bonecp.BoneCPConfig)3 Properties (java.util.Properties)3 HikariConfig (com.zaxxer.hikari.HikariConfig)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)2 ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 CallableStatement (java.sql.CallableStatement)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 DataSource (javax.sql.DataSource)1 XADataSource (javax.sql.XADataSource)1 ConnectionFactory (org.apache.commons.dbcp.ConnectionFactory)1 DriverManagerConnectionFactory (org.apache.commons.dbcp.DriverManagerConnectionFactory)1 PoolableConnectionFactory (org.apache.commons.dbcp.PoolableConnectionFactory)1