brizd opened a new issue, #28282:
URL: https://github.com/apache/shardingsphere/issues/28282

   Hi,
   I configured the data source and database and table splitting strategy 
through the JAVA API, upgrading from 5.3.0 to 5.4.0. The default database 
splitting rule is NoneShardingStrategyConfiguration。
   Currently, there is no problem with single data sources for table queries 
that do not participate in database partitioning. When there are multiple data 
sources, it is prompted that the table does not exist.
   
   this is sphere config:
   `@Configuration
   public class ShardingSphereConfig {
   
       @Value("${spring.db.url}")
       private String url;
   
       @Value("${spring.db.username}")
       private String username;
   
       @Value("${spring.db.password}")
       private String password;
   
       @Bean
       public ShardingSphereDataSource shardingSphereDataSource() throws 
SQLException {
           // 创建ShardingSphereDataSource
           Map<String, DataSource> dataSourceMap = new HashMap<>();
           // 配置数据源
           dataSourceMap.put("ds-aa", createDataSource("order_aa"));
           dataSourceMap.put("ds-bb", createDataSource("order_bb"));
   
           StringBuffer actualNodeBuffer = new StringBuffer("${[");
           
dataSourceMap.keySet().forEach(datasource->actualNodeBuffer.append("'"+datasource+"',"));
           String actualNodeStr = actualNodeBuffer.toString().substring(0, 
actualNodeBuffer.toString().length()-1)+"]}";
   
           // 配置分片规则
           ShardingRuleConfiguration shardingRuleConfig = new 
ShardingRuleConfiguration();
   
           //设置默认分库规则
           shardingRuleConfig.setDefaultDatabaseShardingStrategy(new 
NoneShardingStrategyConfiguration());
           //设置分片算法
           
shardingRuleConfig.setShardingAlgorithms(createAlgorithmConfigurations());
   
           // 配置分表规则
           ShardingTableRuleConfiguration orderRuleConfiguration = new 
ShardingTableRuleConfiguration("order", actualNodeStr+".order_$->{0..4}");
           orderRuleConfiguration.setDatabaseShardingStrategy(new 
StandardShardingStrategyConfiguration("order_no", "database-split"));
           orderRuleConfiguration.setTableShardingStrategy(new 
StandardShardingStrategyConfiguration("order_no", "order-no-split"));
           shardingRuleConfig.getTables().add(orderRuleConfiguration);
   
           return (ShardingSphereDataSource) 
ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, 
Collections.singleton(shardingRuleConfig), new Properties());
       }
   
       private Map<String, AlgorithmConfiguration> 
createAlgorithmConfigurations(){
           Map<String, AlgorithmConfiguration> algorithmConfigurations = new 
HashMap<>();
           Properties databaseProperties = new Properties();
           databaseProperties.setProperty("strategy","standard");
           databaseProperties.setProperty("algorithmClassName", 
"com.uni.sharding.DBShardingAlgorithm");
           AlgorithmConfiguration dbConfiguration = new 
AlgorithmConfiguration("CLASS_BASED", databaseProperties);
           algorithmConfigurations.put("database-split", dbConfiguration);
   
           Properties orderNoProperties = new Properties();
           orderNoProperties.setProperty("strategy","standard");
           orderNoProperties.setProperty("algorithmClassName", 
"com.uni.sharding.TableFulfillmentNoShardingAlgorithm");
           AlgorithmConfiguration orderNoConfiguration = new 
AlgorithmConfiguration("CLASS_BASED", orderNoProperties);
           algorithmConfigurations.put("order-no-split", orderNoConfiguration);
   
           return algorithmConfigurations;
       }
   
       private DataSource createDataSource(final String dataSourceName){
           DruidDataSource dataSource = new DruidDataSource();
           dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
           dataSource.setUrl(String.format(url, dataSourceName));
           dataSource.setUsername(username);
           dataSource.setPassword(password);
           dataSource.setMaxActive(500);
           dataSource.setInitialSize(5);
           dataSource.setMaxWait(60000);
           dataSource.setMinIdle(10);
           dataSource.setTimeBetweenEvictionRunsMillis(60000);
           dataSource.setMinEvictableIdleTimeMillis(300000);
           dataSource.setValidationQuery("SELECT 1");
           dataSource.setTestWhileIdle(true);
           dataSource.setTestOnBorrow(false);
           dataSource.setTestOnReturn(false);
           return dataSource;
       }
   }`
   
   there is an error when query table of no separate database:
   
![image](https://github.com/apache/shardingsphere/assets/24850746/86b8cedb-c252-4be6-bfde-b5504397ac93)
   
   


-- 
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.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to