use of com.ctrip.platform.dal.dao.configure.DatabasePoolConfig in project dal by ctripcorp.
the class DatabasePoolConfigParserTest method test4.
@Test
public void test4() {
DatabasePoolConfig config = DatabasePoolConfigParser.getInstance().getDatabasePoolConifg("dao_test_select");
Assert.assertEquals("dao_test_select", config.getName());
Assert.assertEquals(1000, config.getPoolProperties().getMaxWait());
Assert.assertEquals("rewriteBatchedStatements=true;allowMultiQueries=true", config.getPoolProperties().getConnectionProperties());
}
use of com.ctrip.platform.dal.dao.configure.DatabasePoolConfig in project dal by ctripcorp.
the class DatabasePoolConfigParserTest method test3.
@Test
public void test3() {
DatabasePoolConfig config = DatabasePoolConfigParser.getInstance().getDatabasePoolConifg("dal_test_new");
Assert.assertEquals("dal_test_new", config.getName());
Assert.assertEquals(10000, config.getPoolProperties().getMaxWait());
Assert.assertEquals("sendTimeAsDateTime=false", config.getPoolProperties().getConnectionProperties());
// Test default settings
Assert.assertEquals(30000, config.getPoolProperties().getMaxAge());
}
use of com.ctrip.platform.dal.dao.configure.DatabasePoolConfig in project dal by ctripcorp.
the class DatabasePoolConfigParserTest method test1.
@Test
public void test1() {
DatabasePoolConfig config = DatabasePoolConfigParser.getInstance().getDatabasePoolConifg("dao_test");
Assert.assertEquals("dao_test", config.getName());
Assert.assertEquals(10000, config.getPoolProperties().getMaxWait());
Assert.assertEquals("sendTimeAsDateTime=false;sendStringParametersAsUnicode=false;rewriteBatchedStatements=true;allowMultiQueries=true;useUnicode=true;characterEncoding=UTF-8", config.getPoolProperties().getConnectionProperties());
}
use of com.ctrip.platform.dal.dao.configure.DatabasePoolConfig in project dal by ctripcorp.
the class DataSourceLocator method createDataSource.
private DataSource createDataSource(String name) throws SQLException {
DatabasePoolConfig poolConfig = DatabasePoolConfigParser.getInstance().getDatabasePoolConifg(name);
DataSourceConfigure config = provider.getDataSourceConfigure(name);
if (config == null && poolConfig == null) {
throw new SQLException("Can not find any connection configure for " + name);
}
if (poolConfig == null) {
// Create default connection pool configure
poolConfig = new DatabasePoolConfig();
}
PoolProperties p = poolConfig.getPoolProperties();
/**
* It is assumed that user name/password/url/driver class name are provided in pool config
* If not, it should be provided by the config provider
*/
if (config != null) {
p.setUrl(config.getConnectionUrl());
p.setUsername(config.getUserName());
p.setPassword(config.getPassword());
p.setDriverClassName(config.getDriverClass());
}
org.apache.tomcat.jdbc.pool.DataSource ds = new org.apache.tomcat.jdbc.pool.DataSource(p);
ds.createPool();
logger.info("Datasource[name=" + name + ", Driver=" + p.getDriverClassName() + "] created.");
return ds;
}
use of com.ctrip.platform.dal.dao.configure.DatabasePoolConfig in project dal by ctripcorp.
the class DatabasePoolConfigParserTest method test2.
@Test
public void test2() {
DatabasePoolConfig config = DatabasePoolConfigParser.getInstance().getDatabasePoolConifg("dao_test_select");
Assert.assertEquals("dao_test_select", config.getName());
Assert.assertEquals(true, config.getPoolProperties().isTestWhileIdle());
Assert.assertEquals(true, config.getPoolProperties().isTestOnBorrow());
Assert.assertEquals("SELECT 1", config.getPoolProperties().getValidationQuery());
Assert.assertEquals(30000, config.getPoolProperties().getValidationInterval());
Assert.assertEquals(30000, config.getPoolProperties().getTimeBetweenEvictionRunsMillis());
Assert.assertEquals(100, config.getPoolProperties().getMaxActive());
Assert.assertEquals(10, config.getPoolProperties().getMinIdle());
Assert.assertEquals(1000, config.getPoolProperties().getMaxWait());
Assert.assertEquals(10, config.getPoolProperties().getInitialSize());
Assert.assertEquals(60, config.getPoolProperties().getRemoveAbandonedTimeout());
Assert.assertEquals(true, config.getPoolProperties().isRemoveAbandoned());
Assert.assertEquals(true, config.getPoolProperties().isLogAbandoned());
Assert.assertEquals(30000, config.getPoolProperties().getMinEvictableIdleTimeMillis());
Assert.assertEquals("rewriteBatchedStatements=true;allowMultiQueries=true", config.getPoolProperties().getConnectionProperties());
}
Aggregations