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

   I used the code shown below, but I got error:
   `Caused by: 
org.apache.shardingsphere.infra.exception.kernel.metadata.TableNotFoundException:
 Table or view 'bigorder_transaction' does not exist.
        at 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder.lambda$checkTableExists$12(SimpleTableSegmentBinder.java:178)
        at 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions.checkState(ShardingSpherePreconditions.java:44)
        at 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder.checkTableExists(SimpleTableSegmentBinder.java:178)
        at 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder.bind(SimpleTableSegmentBinder.java:90)
        at 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.TableSegmentBinder.bind(TableSegmentBinder.java:57)
        at 
org.apache.shardingsphere.infra.binder.engine.statement.dml.SelectStatementBinder.lambda$bind$1(SelectStatementBinder.java:64)
        at java.base/java.util.Optional.map(Optional.java:260)
        at 
org.apache.shardingsphere.infra.binder.engine.statement.dml.SelectStatementBinder.bind(SelectStatementBinder.java:64)`
   I confirmed the table is exist in the database
   
   please help!!!!!!
   
   **shardingsphere version: 5.5.2**
   **springboot version:3.4.8**
   **jdk version:21**
   
   `@Configuration
   @Slf4j
   public class BigOrderShardingConfig {
       @Resource
       private ShardingConfigProperty shardingConfigProperty;
   
   
       @Value("${sharding.sql.show:true}")
       private String showSql;
   
       @Bean("DataSource")
       @Primary
       public DataSource getDataSource() throws SQLException {
           Properties properties = new Properties();
           properties.setProperty("sql-show", showSql);
           return 
ShardingSphereDataSourceFactory.createDataSource(buildDataSourceMap(), 
Lists.newArrayList(createSingleRuleConfiguration(), 
createShardingRuleConfiguration(), 
createReadwriteSplittingRuleConfiguration()), properties);
       }
   
   
       private ShardingRuleConfiguration createShardingRuleConfiguration() {
           ShardingRuleConfiguration result = new ShardingRuleConfiguration();
           
result.getShardingAlgorithms().put("bigorder_transaction_table_inline", new 
AlgorithmConfiguration("CLASS_BASED", props("STANDARD", 
OrderNoTableShardingAlgorithm.class.getName())));
           
result.getShardingAlgorithms().put("bigorder_transaction_database_inline", new 
AlgorithmConfiguration("CLASS_BASED", props("STANDARD", 
OrderNoDatabaseShardingAlgorithm.class.getName())));
           
result.getTables().add(getBigOrderTransactionTableRuleConfiguration());
           return result;
       }
   
   
       private static Properties props(String strategy, String className) {
           Properties props = new Properties();
           props.setProperty("strategy", strategy);
           props.setProperty("algorithmClassName", className);
           return props;
       }
   
       private SingleRuleConfiguration createSingleRuleConfiguration() {
           SingleRuleConfiguration singleRuleConfiguration = new 
SingleRuleConfiguration();
           singleRuleConfiguration.setTables(Lists.newArrayList("*.*"));
           singleRuleConfiguration.setDefaultDataSource("ds_bigorder");
           return singleRuleConfiguration;
       }
   
       private ShardingTableRuleConfiguration 
getBigOrderTransactionTableRuleConfiguration() {
           ShardingTableRuleConfiguration result = new 
ShardingTableRuleConfiguration("bigorder_transaction", 
"ds_bigorder_transaction_${0..9}.bigorder_transaction_${25..30}0${1..9}_0${0..9},ds_bigorder_transaction_${0..9}.bigorder_transaction_${25..30}0${1..9}_${10..99},ds_bigorder_transaction_${0..9}.bigorder_transaction_${25..30}${10..12}_0${0..9},ds_bigorder_transaction_${0..9}.bigorder_transaction_${25..30}${10..12}_${10..99}");
           result.setTableShardingStrategy(new 
StandardShardingStrategyConfiguration("order_no", 
"bigorder_transaction_table_inline"));
           result.setDatabaseShardingStrategy(new 
StandardShardingStrategyConfiguration("order_no", 
"bigorder_transaction_database_inline"));
           return result;
       }
   
       private ReadwriteSplittingRuleConfiguration 
createReadwriteSplittingRuleConfiguration() {
           Map<String, AlgorithmConfiguration> algorithmConfigMap = new 
HashMap<>();
           algorithmConfigMap.put("round_robin", new 
AlgorithmConfiguration("ROUND_ROBIN", new Properties()));
           List<ReadwriteSplittingDataSourceGroupRuleConfiguration> 
readwriteSplittingDataSourceRuleConfigurations = new ArrayList<>();
           shardingConfigProperty.getDataSources().forEach((key, value) -> {
               if (StringUtils.isNotBlank(value.getReadUrls())) {
                   List<String> readDatasourceNames = new ArrayList<>();
                   for (int i = 0; i < value.getReadUrls().split(",").length; 
i++) {
                       readDatasourceNames.add(key + "-slave-" + i);
                   }
                   ReadwriteSplittingDataSourceGroupRuleConfiguration 
dataSourceConfig = new ReadwriteSplittingDataSourceGroupRuleConfiguration(key, 
key + "-master", readDatasourceNames, "round_robin");
                   
readwriteSplittingDataSourceRuleConfigurations.add(dataSourceConfig);
               }
           });
           return new 
ReadwriteSplittingRuleConfiguration(readwriteSplittingDataSourceRuleConfigurations,
 algorithmConfigMap);
       }
   
   
   
       private Map<String, DataSource> buildDataSourceMap() {
           Map<String, DataSource> dataSourceMap = new HashMap<>();
           shardingConfigProperty.getDataSources().forEach((key, value) -> {
               dataSourceMap.put(key + "-master", 
createDataSource(value.getUrl(), value.getUsername(), value.getPassword(), 
shardingConfigProperty.getPoolSize(), value.getDriverClassName()));
               for (int i = 0; i < value.getReadUrls().split(",").length; i++) {
                   dataSourceMap.put(key + "-slave-" + i, 
createDataSource(value.getReadUrls().split(",")[i], value.getUsername(), 
value.getPassword(), shardingConfigProperty.getPoolSize(), 
value.getDriverClassName()));
               }
           });
           log.info("shardingDataSourceMap: {}", dataSourceMap);
           return dataSourceMap;
       }
   
       private static DataSource createDataSource(String url, String username, 
String password, int poolSize, String driverClassName) {
           HikariDataSource dataSource = new HikariDataSource();
           dataSource.setJdbcUrl(url);
           dataSource.setUsername(username);
           dataSource.setPassword(password);
           dataSource.setMaximumPoolSize(poolSize);
           dataSource.setMinimumIdle(poolSize);
           dataSource.setDriverClassName(driverClassName);
           dataSource.setConnectionInitSql("SELECT 1");
           dataSource.setConnectionTestQuery("SELECT 1");
           dataSource.setPoolName("transaction-management-datasource-pool");
           dataSource.setIdleTimeout(600000);
           dataSource.setMaxLifetime(1800000);
           dataSource.setConnectionTimeout(30000);
           return dataSource;
       }
   
   }`


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