use of com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource in project quickutil by quickutil.
the class JdbcUtil method getDataSource.
private static ComboPooledDataSource getDataSource(String jdbcUrl, String username, String password, int initconnum, int minconnum, int maxconnum, Properties c3p0) {
if (jdbcUrl == null || username == null || password == null) {
return null;
}
ComboPooledDataSource datasource = new ComboPooledDataSource();
try {
datasource.setDriverClass("com.mysql.jdbc.Driver");
datasource.setJdbcUrl(jdbcUrl);
datasource.setUser(username);
datasource.setPassword(password);
datasource.setInitialPoolSize(initconnum);
datasource.setMinPoolSize(minconnum);
datasource.setMaxPoolSize(maxconnum);
// properties
if (c3p0 == null)
return datasource;
if (c3p0.getProperty("AcquireIncrement") != null)
datasource.setAcquireIncrement(Integer.parseInt(c3p0.getProperty("AcquireIncrement")));
if (c3p0.getProperty("AcquireRetryAttempts") != null)
datasource.setAcquireRetryAttempts(Integer.parseInt(c3p0.getProperty("AcquireRetryAttempts")));
if (c3p0.getProperty("AcquireRetryDelay") != null)
datasource.setAcquireRetryDelay(Integer.parseInt(c3p0.getProperty("AcquireRetryDelay")));
if (c3p0.getProperty("AutoCommitOnClose") != null)
datasource.setAutoCommitOnClose(Boolean.parseBoolean(c3p0.getProperty("AutoCommitOnClose")));
if (c3p0.getProperty("AutomaticTestTable") != null)
datasource.setAutomaticTestTable(c3p0.getProperty("AutomaticTestTable"));
if (c3p0.getProperty("BreakAfterAcquireFailure") != null)
datasource.setBreakAfterAcquireFailure(Boolean.parseBoolean(c3p0.getProperty("BreakAfterAcquireFailure")));
if (c3p0.getProperty("CheckoutTimeout") != null)
datasource.setCheckoutTimeout(Integer.parseInt(c3p0.getProperty("CheckoutTimeout")));
if (c3p0.getProperty("ConnectionCustomizerClassName") != null)
datasource.setConnectionCustomizerClassName(c3p0.getProperty("ConnectionCustomizerClassName"));
if (c3p0.getProperty("ConnectionTesterClassName") != null)
datasource.setConnectionTesterClassName(c3p0.getProperty("ConnectionTesterClassName"));
if (c3p0.getProperty("ContextClassLoaderSource") != null)
datasource.setContextClassLoaderSource(c3p0.getProperty("ContextClassLoaderSource"));
if (c3p0.getProperty("DataSourceName") != null)
datasource.setDataSourceName(c3p0.getProperty("DataSourceName"));
if (c3p0.getProperty("DebugUnreturnedConnectionStackTraces") != null)
datasource.setDebugUnreturnedConnectionStackTraces(Boolean.parseBoolean(c3p0.getProperty("DebugUnreturnedConnectionStackTraces")));
if (c3p0.getProperty("Description") != null)
datasource.setDescription(c3p0.getProperty("Description"));
if (c3p0.getProperty("DriverClass") != null)
datasource.setDriverClass(c3p0.getProperty("DriverClass"));
if (c3p0.getProperty("FactoryClassLocation") != null)
datasource.setFactoryClassLocation(c3p0.getProperty("FactoryClassLocation"));
if (c3p0.getProperty("ForceIgnoreUnresolvedTransactions") != null)
datasource.setForceIgnoreUnresolvedTransactions(Boolean.parseBoolean(c3p0.getProperty("ForceIgnoreUnresolvedTransactions")));
if (c3p0.getProperty("ForceSynchronousCheckins") != null)
datasource.setForceSynchronousCheckins(Boolean.parseBoolean(c3p0.getProperty("ForceSynchronousCheckins")));
if (c3p0.getProperty("ForceUseNamedDriverClass") != null)
datasource.setForceUseNamedDriverClass(Boolean.parseBoolean(c3p0.getProperty("ForceUseNamedDriverClass")));
if (c3p0.getProperty("IdentityToken") != null)
datasource.setIdentityToken(c3p0.getProperty("IdentityToken"));
if (c3p0.getProperty("IdleConnectionTestPeriod") != null)
datasource.setIdleConnectionTestPeriod(Integer.parseInt(c3p0.getProperty("IdleConnectionTestPeriod")));
if (c3p0.getProperty("LoginTimeout") != null)
datasource.setLoginTimeout(Integer.parseInt(c3p0.getProperty("LoginTimeout")));
if (c3p0.getProperty("MaxAdministrativeTaskTime") != null)
datasource.setMaxAdministrativeTaskTime(Integer.parseInt(c3p0.getProperty("MaxAdministrativeTaskTime")));
if (c3p0.getProperty("MaxConnectionAge") != null)
datasource.setMaxConnectionAge(Integer.parseInt(c3p0.getProperty("MaxConnectionAge")));
if (c3p0.getProperty("MaxIdleTime") != null)
datasource.setMaxIdleTime(Integer.parseInt(c3p0.getProperty("MaxIdleTime")));
if (c3p0.getProperty("MaxStatements") != null)
datasource.setMaxStatements(Integer.parseInt(c3p0.getProperty("MaxStatements")));
if (c3p0.getProperty("MaxStatementsPerConnection") != null)
datasource.setMaxStatementsPerConnection(Integer.parseInt(c3p0.getProperty("MaxStatementsPerConnection")));
if (c3p0.getProperty("NumHelperThreads") != null)
datasource.setNumHelperThreads(Integer.parseInt(c3p0.getProperty("NumHelperThreads")));
if (c3p0.getProperty("OverrideDefaultPassword") != null)
datasource.setOverrideDefaultPassword(c3p0.getProperty("OverrideDefaultPassword"));
if (c3p0.getProperty("OverrideDefaultUser") != null)
datasource.setOverrideDefaultUser(c3p0.getProperty("OverrideDefaultUser"));
if (c3p0.getProperty("PreferredTestQuery") != null)
datasource.setPreferredTestQuery(c3p0.getProperty("PreferredTestQuery"));
if (c3p0.getProperty("PrivilegeSpawnedThreads") != null)
datasource.setPrivilegeSpawnedThreads(Boolean.parseBoolean(c3p0.getProperty("PrivilegeSpawnedThreads")));
if (c3p0.getProperty("PropertyCycle") != null)
datasource.setPropertyCycle(Integer.parseInt(c3p0.getProperty("PropertyCycle")));
if (c3p0.getProperty("StatementCacheNumDeferredCloseThreads") != null)
datasource.setStatementCacheNumDeferredCloseThreads(Integer.parseInt(c3p0.getProperty("StatementCacheNumDeferredCloseThreads")));
if (c3p0.getProperty("TestConnectionOnCheckin") != null)
datasource.setTestConnectionOnCheckin(Boolean.parseBoolean(c3p0.getProperty("TestConnectionOnCheckin")));
if (c3p0.getProperty("TestConnectionOnCheckout") != null)
datasource.setTestConnectionOnCheckout(Boolean.parseBoolean(c3p0.getProperty("TestConnectionOnCheckout")));
if (c3p0.getProperty("UnreturnedConnectionTimeout") != null)
datasource.setUnreturnedConnectionTimeout(Integer.parseInt(c3p0.getProperty("UnreturnedConnectionTimeout")));
if (c3p0.getProperty("UserOverridesAsString") != null)
datasource.setUserOverridesAsString(c3p0.getProperty("UserOverridesAsString"));
if (c3p0.getProperty("UsesTraditionalReflectiveProxies") != null)
datasource.setUsesTraditionalReflectiveProxies(Boolean.parseBoolean(c3p0.getProperty("UsesTraditionalReflectiveProxies")));
} catch (Exception e) {
LogUtil.error(e, "c3p0配置错误");
}
return datasource;
}
use of com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource in project hutool by looly.
the class C3p0DSFactory method getDataSource.
@Override
public synchronized DataSource getDataSource(String group) {
if (group == null) {
group = StrUtil.EMPTY;
}
// 如果已经存在已有数据源(连接池)直接返回
final ComboPooledDataSource existedDataSource = dsMap.get(group);
if (existedDataSource != null) {
return existedDataSource;
}
ComboPooledDataSource ds = createDataSource(group);
// 添加到数据源池中,以备下次使用
dsMap.put(group, ds);
return ds;
}
use of com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource in project hutool by looly.
the class C3p0DSFactory method destroy.
@Override
public void destroy() {
if (CollectionUtil.isNotEmpty(dsMap)) {
Collection<ComboPooledDataSource> values = dsMap.values();
for (ComboPooledDataSource ds : values) {
ds.close();
}
dsMap.clear();
}
}
use of com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource in project Logos_Materials_October_2017 by VolodymyrZavada.
the class DatabaseConfig method getDataSource.
@Bean
public DataSource getDataSource() throws PropertyVetoException {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setDriverClass(env.getProperty("spring.datasource.driver"));
dataSource.setJdbcUrl(env.getProperty("spring.datasource.url"));
dataSource.setUser(env.getProperty("spring.datasource.username"));
dataSource.setPassword(env.getProperty("spring.datasource.password"));
dataSource.setMaxPoolSize(Integer.parseInt(env.getRequiredProperty("spring.datasource.c3p0.maximum-pool-size")));
dataSource.setMinPoolSize(Integer.parseInt(env.getRequiredProperty("spring.datasource.c3p0.minimum-pool-size")));
dataSource.setMaxIdleTime(Integer.parseInt(env.getRequiredProperty("spring.datasource.c3p0.connection-timeout")));
// dataSource.setMaxStatements(Integer.parseInt(env.getRequiredProperty("spring.datasource.c3p0.maximum-statements")));
return dataSource;
}
use of com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource in project Logos_Materials_October_2017 by VolodymyrZavada.
the class DatabaseConfig method getDataSource.
@Bean
public DataSource getDataSource() throws PropertyVetoException {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setDriverClass(env.getProperty("spring.datasource.driver"));
dataSource.setJdbcUrl(env.getProperty("spring.datasource.url"));
dataSource.setUser(env.getProperty("spring.datasource.username"));
dataSource.setPassword(env.getProperty("spring.datasource.password"));
dataSource.setMaxPoolSize(Integer.parseInt(env.getRequiredProperty("spring.datasource.c3p0.maximum-pool-size")));
dataSource.setMinPoolSize(Integer.parseInt(env.getRequiredProperty("spring.datasource.c3p0.minimum-pool-size")));
dataSource.setMaxIdleTime(Integer.parseInt(env.getRequiredProperty("spring.datasource.c3p0.connection-timeout")));
// dataSource.setMaxStatements(Integer.parseInt(env.getRequiredProperty("spring.datasource.c3p0.maximum-statements")));
return dataSource;
}
Aggregations