TeslaCN opened a new issue #15767:
URL: https://github.com/apache/shardingsphere/issues/15767


   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   
   - 5.1.0
   - 022be4cc6aa8b9e6644be9e4115a95a34430b2f5
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   
   ### Expected behavior
   
   Got empty array.
   
   ### Actual behavior
   
   ```
   Exception in thread "main" java.lang.NullPointerException: Cannot invoke 
"org.apache.shardingsphere.infra.executor.sql.context.ExecutionContext.getRouteContext()"
 because "this.executionContext" is null
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.initBatchPreparedStatementExecutor(ShardingSpherePreparedStatement.java:547)
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeBatch(ShardingSpherePreparedStatement.java:531)
        at 
icu.wwj.shardingsphere.jdbc.ShardingSphereBatchedInserts.main(ShardingSphereBatchedInserts.java:26)
   ```
   
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   ### Example codes for reproduce this issue (such as a github link).
   
   ```java
   package icu.wwj.shardingsphere.jdbc;
   
   import lombok.SneakyThrows;
   
   import javax.sql.DataSource;
   import java.sql.Connection;
   import java.sql.PreparedStatement;
   
   public final class ShardingSphereBatchedInserts {
       
       private final static DataSource DATA_SOURCE = 
ShardingSpheres.createShardingSphereDataSource("/shardingsphere-jdbc/config-sharding-og.yaml");
       
       public static void main(String[] args) throws Exception {
           try (Connection connection = getConnection()) {
               try (PreparedStatement preparedStatement = 
connection.prepareStatement("insert into bmsql_order_line (ol_w_id) values 
(?)")) {
                   preparedStatement.executeBatch();
               }
           }
       }
       
       @SneakyThrows
       private static Connection getConnection() {
           return DATA_SOURCE.getConnection();
       }
   }
   
   ```


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