use of com.ctrip.platform.dal.dao.configure.DalConnectionString in project dal by ctripcorp.
the class PropertyFileConnectionStringProvider method getConnectionStrings.
@Override
public Map<String, DalConnectionString> getConnectionStrings(Set<String> names) throws Exception {
if (names == null || names.isEmpty())
return null;
Map<String, DalConnectionString> map = new HashMap<>();
for (String name : names) {
StringBuilder sb = new StringBuilder();
sb.append(properties.getProperty(name + USER_NAME));
sb.append(COMMA);
sb.append(properties.getProperty(name + PASSWORD));
sb.append(COMMA);
sb.append(properties.getProperty(name + CONNECTION_URL));
sb.append(COMMA);
sb.append(properties.getProperty(name + DRIVER_CLASS_NAME));
DalConnectionString connectionString = new ConnectionString(name, sb.toString(), sb.toString());
map.put(name, connectionString);
}
return map;
}
use of com.ctrip.platform.dal.dao.configure.DalConnectionString in project dal by ctripcorp.
the class PropertyFileConnectionStringProviderTest method testPropertyFileConnectionStringProvider.
@Test
public void testPropertyFileConnectionStringProvider() throws Exception {
PropertyFileConnectionStringProvider provider = new PropertyFileConnectionStringProvider();
Set<String> names = new HashSet<>();
names.add(NAME);
Map<String, DalConnectionString> map = provider.getConnectionStrings(names);
DalConnectionString connectionString = map.get(NAME);
String cs = connectionString.getIPConnectionString();
String[] array = cs.split(COMMA);
Assert.assertEquals(array[0], "testUser");
Assert.assertEquals(array[1], "testPassword");
Assert.assertEquals(array[2], "jdbc:mysql://testIP:3306/testDb");
Assert.assertEquals(array[3], "com.mysql.jdbc.Driver");
}
Aggregations