This is an automated email from the ASF dual-hosted git repository.

tuichenchuxin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 4430476e737 Fix local transaction auto commit in jdbc adapter. (#29848)
4430476e737 is described below

commit 4430476e7372f75df00af40e7054e7ef08ef331b
Author: Cong Hu <[email protected]>
AuthorDate: Thu Jan 25 14:36:15 2024 +0800

    Fix local transaction auto commit in jdbc adapter. (#29848)
---
 .../driver/jdbc/core/connection/ShardingSphereConnection.java | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git 
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
 
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
index c4f0d7631bf..764c9dcf43d 100644
--- 
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
+++ 
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
@@ -185,13 +185,16 @@ public final class ShardingSphereConnection extends 
AbstractConnectionAdapter {
     
     /**
      * Handle auto commit.
-     * 
+     *
      * @throws SQLException SQL exception
      */
     public void handleAutoCommit() throws SQLException {
-        if (!autoCommit && 
TransactionType.isDistributedTransaction(databaseConnectionManager.getConnectionTransaction().getTransactionType())
-                && 
!databaseConnectionManager.getConnectionTransaction().isInTransaction()) {
-            beginDistributedTransaction();
+        if (!autoCommit && 
!databaseConnectionManager.getConnectionTransaction().isInTransaction()) {
+            if 
(TransactionType.isDistributedTransaction(databaseConnectionManager.getConnectionTransaction().getTransactionType()))
 {
+                beginDistributedTransaction();
+            } else {
+                
getConnectionContext().getTransactionContext().setInTransaction(true);
+            }
         }
     }
     

Reply via email to