Search in sources :

Example 16 with ComboPooledDataSource

use of com.mchange.v2.c3p0.ComboPooledDataSource in project druid by alibaba.

the class Case4 method test_c3p0.

public void test_c3p0() throws Exception {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    // dataSource.(10);
    // dataSource.setMaxActive(50);
    dataSource.setMinPoolSize(minPoolSize);
    dataSource.setMaxPoolSize(maxPoolSize);
    dataSource.setDriverClass(driverClass);
    dataSource.setJdbcUrl(jdbcUrl);
    dataSource.setMaxStatements(maxOpenPreparedStatements);
    dataSource.setUser(user);
    dataSource.setPassword(password);
    for (int i = 0; i < loopCount; ++i) {
        p0(dataSource, "c3p0", threadCount);
    }
    System.out.println();
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource)

Example 17 with ComboPooledDataSource

use of com.mchange.v2.c3p0.ComboPooledDataSource in project druid by alibaba.

the class TestPSCache method f_test_c3p0.

public void f_test_c3p0() throws Exception {
    ComboPooledDataSource ds = new ComboPooledDataSource();
    ds.setJdbcUrl("jdbc:mock:test");
    ds.setMaxPoolSize(10);
    ds.setMinPoolSize(0);
    ds.setMaxStatements(10);
    for (int i = 0; i < 10; ++i) {
        f(ds, 5);
        System.out.println("--------------------------------------------");
    }
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource)

Example 18 with ComboPooledDataSource

use of com.mchange.v2.c3p0.ComboPooledDataSource in project opennms by OpenNMS.

the class ConnectionTrackerTest method testC3poDatabaseConnection.

@Test
@Ignore
public void testC3poDatabaseConnection() throws Exception {
    final ComboPooledDataSource cpds = new ComboPooledDataSource();
    cpds.setDriverClass("org.postgresql.Driver");
    cpds.setUser("opennms");
    cpds.setJdbcUrl("jdbc:postgresql://localhost:5432/template1");
    final Connection conn = cpds.getConnection();
    assertEquals(1, Connections.getPooledConnectionCount());
    Connections.printPooledStatus();
    conn.close();
    assertEquals(0, Connections.getPooledConnectionCount());
    Connections.printPooledStatus();
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) Connection(java.sql.Connection) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 19 with ComboPooledDataSource

use of com.mchange.v2.c3p0.ComboPooledDataSource in project midpoint by Evolveum.

the class DataSourceFactory method destroy.

public void destroy() {
    if (dataSource instanceof ComboPooledDataSource) {
        ComboPooledDataSource ds = (ComboPooledDataSource) dataSource;
        ds.close();
    }
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource)

Example 20 with ComboPooledDataSource

use of com.mchange.v2.c3p0.ComboPooledDataSource in project midpoint by Evolveum.

the class DataSourceFactory method createC3P0DataSource.

private DataSource createC3P0DataSource() throws PropertyVetoException {
    ComboPooledDataSource ds = new ComboPooledDataSource();
    ds.setDriverClass(configuration.getDriverClassName());
    ds.setJdbcUrl(configuration.getJdbcUrl());
    ds.setUser(configuration.getJdbcUsername());
    ds.setPassword(configuration.getJdbcPassword());
    ds.setAcquireIncrement(3);
    ds.setMinPoolSize(configuration.getMinPoolSize());
    ds.setMaxPoolSize(configuration.getMaxPoolSize());
    ds.setIdleConnectionTestPeriod(1800);
    ds.setConnectionTesterClassName(MidPointConnectionTester.class.getName());
    ds.setConnectionCustomizerClassName(MidPointConnectionCustomizer.class.getName());
    return ds;
}
Also used : MidPointConnectionTester(com.evolveum.midpoint.repo.sql.util.MidPointConnectionTester) ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) MidPointConnectionCustomizer(com.evolveum.midpoint.repo.sql.util.MidPointConnectionCustomizer)

Aggregations

ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)23 SQLException (java.sql.SQLException)6 PropertyVetoException (java.beans.PropertyVetoException)4 Properties (java.util.Properties)3 ArrayList (java.util.ArrayList)2 DataSource (javax.sql.DataSource)2 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)1 MidPointConnectionCustomizer (com.evolveum.midpoint.repo.sql.util.MidPointConnectionCustomizer)1 MidPointConnectionTester (com.evolveum.midpoint.repo.sql.util.MidPointConnectionTester)1 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)1 BoneCPConfig (com.jolbox.bonecp.BoneCPConfig)1 BoneCPDataSource (com.jolbox.bonecp.BoneCPDataSource)1 DatabusException (com.linkedin.databus2.core.DatabusException)1 HikariConfig (com.zaxxer.hikari.HikariConfig)1 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 CallableStatement (java.sql.CallableStatement)1 Connection (java.sql.Connection)1