pototallxg commented on issue #4604:
URL: https://github.com/apache/shardingsphere/issues/4604#issuecomment-747824272
public DataSource shardingDataSource(Map<String, DataSource>
dataSourceMap) throws SQLException {
ShardingRuleConfiguration shardingRuleConfig = new
ShardingRuleConfiguration();
Collection<ShardingTableRuleConfiguration> tables = new
ArrayList<>();
tables.add(new ShardingTableRuleConfiguration("HSale_Key",
"cunfang-slave0.HSale_Key"));
tables.add(new ShardingTableRuleConfiguration("HSale_ShiKan",
"cunfang-slave0.HSale_ShiKan"));
ShardingStrategyConfiguration dbShardingConfig = new
HintShardingStrategyConfiguration("dbShardingAlgorithm");
Properties dbShardingAlgorithmrProps = new Properties();
dbShardingAlgorithmrProps.setProperty("algorithm-class-name",
"com.cunfang.house.dbengine.shardingconfig.dbsharding.DataSourceRoutingAlgorithm");
shardingRuleConfig.getShardingAlgorithms().put("dbShardingAlgorithm", new
ShardingSphereAlgorithmConfiguration("INLINE", dbShardingAlgorithmrProps));
ShardingStrategyConfiguration tableShardingConfig = new
HintShardingStrategyConfiguration("tableShardingAlgorithm");
Properties tableShardingAlgorithmrProps = new Properties();
tableShardingAlgorithmrProps.setProperty("algorithm-class-name",
"com.cunfang.house.dbengine.shardingconfig.tablesharding.TableKeyHintShardingAlgorithm");
shardingRuleConfig.getShardingAlgorithms().put("dbShardingAlgorithm", new
ShardingSphereAlgorithmConfiguration("INLINE", tableShardingAlgorithmrProps));
shardingRuleConfig.setDefaultDatabaseShardingStrategy(dbShardingConfig);
shardingRuleConfig.setDefaultTableShardingStrategy(tableShardingConfig);
shardingRuleConfig.setTables(tables);
return
ShardingSphereDataSourceFactory.createDataSource(dataSourceMap,
Collections.singleton(shardingRuleConfig), new Properties());
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]