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

   ## CODE
   
   ```java
       public static void main(String[] args) throws SQLException {
           Map<String, DataSource> dataSourceMap = 
Demo1DatasourceUtils.createDataSourceMap();
           ShardingRuleConfiguration configuration  = new 
ShardingRuleConfiguration();
   
           //设置分片规则
           ShardingTableRuleConfiguration shardingTableRuleConfiguration = new 
ShardingTableRuleConfiguration("abc", "sharding4.brand${1..2}}");
           Properties properties  = new Properties();
           properties.setProperty("sharding-count","2");
           configuration.getShardingAlgorithms().put("mod",new 
ShardingSphereAlgorithmConfiguration("MOD",properties));
   
           //定义分表策略
           StandardShardingStrategyConfiguration 
standardShardingStrategyConfiguration  = new 
StandardShardingStrategyConfiguration("id","mod");
   
           configuration.getTables().add(shardingTableRuleConfiguration);
           
shardingTableRuleConfiguration.setTableShardingStrategy(standardShardingStrategyConfiguration);
           DataSource dataSource = 
ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, 
Collections.singleton(configuration), new Properties());
           dataSource.getConnection().prepareStatement("insert into 
abc(`id`,brand_name) values(2,'xxxxxx')").execute();
           dataSource.getConnection().prepareStatement("insert into 
abc(`id`,brand_name) values(3,'xxxxx')").execute();
       }
   ```
   ## ERROR INFO  
   
   ```java
   Exception in thread "main" java.lang.IllegalStateException: Insert statement 
does not support sharding table routing to multiple data nodes.
        at 
com.google.common.base.Preconditions.checkState(Preconditions.java:508)
        at 
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingInsertStatementValidator.postValidate(ShardingInsertStatementValidator.java:101)
        at 
org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.lambda$createRouteContext$1(ShardingSQLRouter.java:57)
        at java.base/java.util.Optional.ifPresent(Optional.java:183)
        at 
org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:57)
        at 
org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:44)
        at 
org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:73)
        at 
org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:53)
        at 
org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:54)
        at 
org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:46)
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:431)
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:337)
        at com.huige.cn.demo1.example.Example1.main(Example1.java:38)
   
   Process finished with exit code 1
   ````


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