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;
}
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;
}
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;
}
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;
}
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();
}
Aggregations