use of com.dangdang.ddframe.rdb.sharding.config.yaml.api.YamlShardingDataSource in project sharding-jdbc by dangdangdotcom.
the class YamlWithDefaultDataSourceMain method main.
// CHECKSTYLE:OFF
public static void main(final String[] args) throws Exception {
// CHECKSTYLE:ON
YamlShardingDataSource dataSource = new YamlShardingDataSource(new File(YamlWithDefaultDataSourceMain.class.getResource("/META-INF/withDefaultDataSource.yaml").getFile()));
printJoinSelect(dataSource);
printGroupBy(dataSource);
}
use of com.dangdang.ddframe.rdb.sharding.config.yaml.api.YamlShardingDataSource in project sharding-jdbc by dangdangdotcom.
the class YamlIntegratedTest method testWithDataSource.
@Test
public void testWithDataSource() throws SQLException, URISyntaxException, IOException {
File yamlFile = new File(YamlIntegratedTest.class.getResource(filePath).toURI());
DataSource dataSource;
if (hasDataSource) {
dataSource = new YamlShardingDataSource(yamlFile);
} else {
dataSource = new YamlShardingDataSource(Maps.asMap(Sets.newHashSet("db0", "db1"), new Function<String, DataSource>() {
@Override
public DataSource apply(final String key) {
return createDataSource(key);
}
}), yamlFile);
}
try (Connection conn = dataSource.getConnection();
Statement stm = conn.createStatement()) {
stm.executeQuery("SELECT * FROM t_order");
stm.executeQuery("SELECT * FROM t_order_item");
stm.executeQuery("SELECT * FROM config");
}
}
use of com.dangdang.ddframe.rdb.sharding.config.yaml.api.YamlShardingDataSource in project sharding-jdbc by dangdangdotcom.
the class YamlWithAssignedDataSourceMain method main.
// CHECKSTYLE:OFF
public static void main(final String[] args) throws Exception {
// CHECKSTYLE:ON
YamlShardingDataSource dataSource = new YamlShardingDataSource(new File(YamlWithAssignedDataSourceMain.class.getResource("/META-INF/withAssignedDataSource.yaml").getFile()));
printSimpleSelect(dataSource);
printJoinSelect(dataSource);
printGroupBy(dataSource);
}
Aggregations