use of com.ctrip.platform.dal.dao.configure.DataSourceConfigure in project dal by ctripcorp.
the class DatabasePoolConfigParserTest method test4.
@Test
public void test4() {
DataSourceConfigure config = DataSourceConfigureLocator.getInstance().getUserDataSourceConfigure("dao_test_select");
Assert.assertEquals("dao_test_select", config.getName());
Assert.assertEquals(1000, config.getIntProperty(DataSourceConfigureConstants.MAXWAIT, 0));
Assert.assertEquals("rewriteBatchedStatements=true;allowMultiQueries=true", config.getProperty(DataSourceConfigureConstants.CONNECTIONPROPERTIES));
}
use of com.ctrip.platform.dal.dao.configure.DataSourceConfigure in project dal by ctripcorp.
the class DatabasePoolConfigParserTest method test1.
@Test
public void test1() {
DataSourceConfigure config = DataSourceConfigureLocator.getInstance().getUserDataSourceConfigure("dao_test");
Assert.assertEquals("dao_test", config.getName());
Assert.assertEquals(10000, config.getIntProperty(DataSourceConfigureConstants.MAXWAIT, 0));
Assert.assertEquals("sendTimeAsDateTime=false;sendStringParametersAsUnicode=false;rewriteBatchedStatements=true;allowMultiQueries=true;useUnicode=true;characterEncoding=UTF-8", config.getProperty(DataSourceConfigureConstants.OPTION));
}
use of com.ctrip.platform.dal.dao.configure.DataSourceConfigure in project dal by ctripcorp.
the class PropertyFileConnectionStringProvider method getConnectionStrings.
@Override
public Map<String, DataSourceConfigure> getConnectionStrings(Set<String> dbNames) throws Exception {
if (dbNames == null || dbNames.isEmpty())
return null;
Map<String, DataSourceConfigure> map = new HashMap<>();
for (String name : dbNames) {
DataSourceConfigure configure = new DataSourceConfigure();
configure.setUserName(properties.getProperty(name + USER_NAME));
configure.setPassword(properties.getProperty(name + PASSWORD));
configure.setConnectionUrl(properties.getProperty(name + CONNECTION_URL));
configure.setDriverClass(properties.getProperty(name + DRIVER_CLASS_NAME));
map.put(name, configure);
}
return map;
}
use of com.ctrip.platform.dal.dao.configure.DataSourceConfigure in project dal by ctripcorp.
the class DataSourceLocator method createDataSource.
private DataSource createDataSource(String name) throws SQLException {
DataSourceConfigure config = provider.getDataSourceConfigure(name);
if (config == null) {
throw new SQLException("Can not find connection configure for " + name);
}
RefreshableDataSource rds = new RefreshableDataSource(name, config);
provider.register(name, rds);
return rds;
}
use of com.ctrip.platform.dal.dao.configure.DataSourceConfigure in project dal by ctripcorp.
the class DatabasePoolConfigParserTest method test3.
@Test
public void test3() {
DataSourceConfigure config = DataSourceConfigureLocator.getInstance().getUserDataSourceConfigure("dal_test_new");
Assert.assertEquals("dal_test_new", config.getName());
Assert.assertEquals(10000, config.getIntProperty(DataSourceConfigureConstants.MAXWAIT, 0));
Assert.assertEquals("sendTimeAsDateTime=false", config.getProperty(DataSourceConfigureConstants.OPTION));
// Test default settings,now default value is zero
Assert.assertEquals(0, config.getIntProperty(DataSourceConfigureConstants.MAX_AGE, 0));
}
Aggregations