You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/10/20 06:30:06 UTC

[GitHub] [shardingsphere] ICannerxy opened a new issue, #21653: Jdbc batch delete is not supported

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

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   
   5.2.0
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   ShardingSphere-Proxy
   
   ### Expected behavior
   
   Support JDBC Statement addBatch() and executeBatch();
   
   ### Actual behavior
   
   When using jdbc to batch delete data, the expected and actual results are inconsistent.
   
   ### Reason analyze (If you can)
   
   Maybe is a bug.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   1. Table t1 has 2 sub databases and 2 sub tables
   ```sql
   CREATE TABLE `t1` (
     `id` int(11) DEFAULT NULL,
     `name` varchar(222) DEFAULT NULL
   ) ENGINE=InnoDB
   ```
   
   2. insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
   
   3. 
   ```
   public static void main(String[] args) {
           Connection con = null;
           PreparedStatement statement = null;
           try {
               String user = "root";
               String password = "servyou";
               String url = "jdbc:mysql://10.199.157.228:3307/datarktest?useUnicode=true&useSSL=true&characterEncoding=utf8&allowMultiQueries=true&rewriteBatchedStatements=true&useServerPrepStmts=true";
               String driver = "com.mysql.cj.jdbc.Driver";
               //2.加载驱动
               Class.forName(driver);
               //3.获取连接
               con = DriverManager.getConnection(url, user, password);
               con.setAutoCommit(false);
               statement = con.prepareStatement("delete from t1 where id = ?");
               statement.setInt(1, 1);
               statement.addBatch();
               statement.setInt(1, 2);
               statement.addBatch();
               statement.setInt(1, 3);
               statement.addBatch();
               statement.setInt(1, 4);
               statement.addBatch();
               statement.setInt(1, 5);
               statement.addBatch();
               statement.setInt(1, 6);
               statement.addBatch();
               statement.setInt(1, 7);
               statement.addBatch();
               statement.setInt(1, 8);
               statement.addBatch();
               statement.setInt(1, 9);
               statement.addBatch();
               //6.执行操作
               statement.executeBatch();
               con.commit();
           } catch (Exception e) {
               e.printStackTrace();
           } finally {
               //7.资源的关闭
               try {
                   statement.close();
               } catch (SQLException e) {
                   e.printStackTrace();
               }
               try {
                   con.close();
               } catch (SQLException e) {
                   e.printStackTrace();
               }
           }
   
       }
   ```
   
   It is expected that all the data in the table will be deleted, but it is not
   
   ### Example codes for reproduce this issue (such as a github link).
   
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN commented on issue #21653: Jdbc batch delete is not supported

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on issue #21653:
URL: https://github.com/apache/shardingsphere/issues/21653#issuecomment-1285160868

   Please try removing the `allowMultiQueries=true`.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] ICannerxy commented on issue #21653: Jdbc batch delete is not supported

Posted by GitBox <gi...@apache.org>.
ICannerxy commented on issue #21653:
URL: https://github.com/apache/shardingsphere/issues/21653#issuecomment-1285174997

   > 
   
   After deleting the parameter `allowMultiQueries=true`  , an error occurred
   
   ![image](https://user-images.githubusercontent.com/40480377/196903693-c1d5d95d-d23d-49ce-b573-5ff8ac5836ca.png)
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN commented on issue #21653: Jdbc batch delete is not supported

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on issue #21653:
URL: https://github.com/apache/shardingsphere/issues/21653#issuecomment-1285295848

   Could you provide the result of `bin/start.sh -v`?


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN commented on issue #21653: Jdbc batch delete is not supported

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on issue #21653:
URL: https://github.com/apache/shardingsphere/issues/21653#issuecomment-1285299080

   We have handled MySQL multi statement in https://github.com/apache/shardingsphere/pull/16268.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN closed issue #21653: Jdbc batch delete is not supported

Posted by GitBox <gi...@apache.org>.
TeslaCN closed issue #21653: Jdbc batch delete is not supported
URL: https://github.com/apache/shardingsphere/issues/21653


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org