Search in sources :

Example 11 with ComboPooledDataSource

use of com.mchange.v2.c3p0.ComboPooledDataSource in project adempiere by adempiere.

the class DB_Oracle method getDataSource.

//  getCommands
/**
     *  Create DataSource
     *  @param connection connection
     *  @return data dource
     */
public DataSource getDataSource(CConnection connection) {
    if (m_ds != null)
        return m_ds;
    try {
        System.setProperty("com.mchange.v2.log.MLog", "com.mchange.v2.log.FallbackMLog");
        //System.setProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", "ALL");
        ComboPooledDataSource cpds = new ComboPooledDataSource();
        cpds.setDataSourceName("AdempiereDS");
        cpds.setDriverClass(DRIVER);
        //loads the jdbc driver
        cpds.setJdbcUrl(getConnectionURL(connection));
        cpds.setUser(connection.getDbUid());
        cpds.setPassword(connection.getDbPwd());
        cpds.setPreferredTestQuery(DEFAULT_CONN_TEST_SQL);
        cpds.setIdleConnectionTestPeriod(1200);
        cpds.setAcquireRetryAttempts(2);
        if (Ini.isClient()) {
            cpds.setInitialPoolSize(1);
            cpds.setMinPoolSize(1);
            cpds.setMaxPoolSize(15);
            cpds.setMaxIdleTimeExcessConnections(1200);
            cpds.setMaxIdleTime(900);
            m_maxbusyconnections = 10;
        } else {
            cpds.setInitialPoolSize(10);
            cpds.setMinPoolSize(5);
            cpds.setMaxPoolSize(150);
            cpds.setMaxIdleTimeExcessConnections(1200);
            cpds.setMaxIdleTime(1200);
            m_maxbusyconnections = 120;
        }
        //the following sometimes kill active connection!
        //cpds.setUnreturnedConnectionTimeout(1200);
        //cpds.setDebugUnreturnedConnectionStackTraces(true);
        m_ds = cpds;
    } catch (Exception ex) {
        m_ds = null;
        //log might cause infinite loop since it will try to acquire database connection again
        //log.log(Level.SEVERE, "Could not initialise C3P0 Datasource", ex);
        System.err.println("Could not initialise C3P0 Datasource: " + ex.getLocalizedMessage());
    }
    return m_ds;
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) DBException(org.adempiere.exceptions.DBException) SQLException(java.sql.SQLException)

Example 12 with ComboPooledDataSource

use of com.mchange.v2.c3p0.ComboPooledDataSource in project ignite by apache.

the class TcpDiscoveryJdbcIpFinderSelfTest method ipFinder.

/** {@inheritDoc} */
@Override
protected TcpDiscoveryJdbcIpFinder ipFinder() throws Exception {
    TcpDiscoveryJdbcIpFinder finder = new TcpDiscoveryJdbcIpFinder();
    assert finder.isShared() : "IP finder should be shared by default.";
    dataSrc = new ComboPooledDataSource();
    dataSrc.setDriverClass("org.h2.Driver");
    if (initSchema)
        dataSrc.setJdbcUrl("jdbc:h2:mem:./test");
    else {
        dataSrc.setJdbcUrl("jdbc:h2:mem:jdbc_ipfinder_not_initialized_schema");
        finder.setInitSchema(false);
    }
    finder.setDataSource(dataSrc);
    return finder;
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource)

Example 13 with ComboPooledDataSource

use of com.mchange.v2.c3p0.ComboPooledDataSource in project jfinal by jfinal.

the class C3p0Plugin method start.

public boolean start() {
    if (isStarted)
        return true;
    dataSource = new ComboPooledDataSource();
    dataSource.setJdbcUrl(jdbcUrl);
    dataSource.setUser(user);
    dataSource.setPassword(password);
    try {
        dataSource.setDriverClass(driverClass);
    } catch (PropertyVetoException e) {
        dataSource = null;
        System.err.println("C3p0Plugin start error");
        throw new RuntimeException(e);
    }
    dataSource.setMaxPoolSize(maxPoolSize);
    dataSource.setMinPoolSize(minPoolSize);
    dataSource.setInitialPoolSize(initialPoolSize);
    dataSource.setMaxIdleTime(maxIdleTime);
    dataSource.setAcquireIncrement(acquireIncrement);
    isStarted = true;
    return true;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource)

Example 14 with ComboPooledDataSource

use of com.mchange.v2.c3p0.ComboPooledDataSource in project databus by linkedin.

the class MysqlMaxSCNHandler method createConnectionPool.

private static ComboPooledDataSource createConnectionPool(StaticConfig staticConfig) throws DatabusException {
    ComboPooledDataSource cpds = new ComboPooledDataSource();
    try {
        cpds.setDriverClass(staticConfig.getDriverClass());
    } catch (PropertyVetoException e) {
        throw new DatabusException("Unable to create connection pool", e);
    }
    cpds.setJdbcUrl(staticConfig.getJdbcUrl());
    cpds.setUser(staticConfig.getDbUser());
    cpds.setPassword(staticConfig.getDbPassword());
    //TODO : Default connection pool setting, make it configurable
    return cpds;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) DatabusException(com.linkedin.databus2.core.DatabusException)

Example 15 with ComboPooledDataSource

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

the class Case1 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.setPoolPreparedStatements(true);
    // dataSource.setMaxOpenPreparedStatements(100);
    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)

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