Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
None
Description
When using the MySQL OceanBase Connector, calling the rollback(savepoint) operation throws a java.sql.SQLSyntaxErrorException: (conn=xxxx) savepoint doesSQLSyntaxErrorException: (conn=xxxx) savepoint does not exist is thrown, explicitly alerting the user that a transaction rollback point error has occurred;
When using MariaDB, the same operation does not throw any exceptions or errors, which makes it impossible for users to detect transaction control problems in a timely manner, which is a big risk.
This difference is very dangerous, because when the savepoint is invalid, if there is no exception feedback, the user can not notice the transaction rollback failure, which may lead to data consistency and transaction logic abnormalities, affecting the stability and correctness of the system.
Perhaps you need to rework the transaction rollback interface so that it strictly throws exceptions to alert the user!
config
*****************************************************************
|
MYSQL Connector:
|
<dependency>
|
<groupId>com.mysql</groupId>
|
<artifactId>mysql-connector-j</artifactId>
|
<version>9.2.0</version>
|
</dependency>
|
-----------------------------------------------------------------
|
MariaDB Connector:
|
<dependency>
|
<groupId>org.mariadb.jdbc</groupId>
|
<artifactId>mariadb-java-client</artifactId>
|
<version>3.5.3</version>
|
</dependency>
|
-----------------------------------------------------------------
|
javaCode
import java.sql.*; |
|
|
public class TestMysql { |
public static void main(String[] args) throws SQLException { |
Connection con = null; |
Statement stmt = null; |
PreparedStatement pstmt = null; |
ResultSet rs = null; |
Savepoint sp = null; |
|
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/testdb0?user=root&password=1234"); |
//con = DriverManager.getConnection("jdbc:oceanbase://49.52.27.61:2881/database0?user=root@test&password=1234"); |
stmt = con.createStatement(1003, 1007, 1); |
sp = con.setSavepoint("savepoint1"); |
|
try { |
con.setAutoCommit(false); |
} catch (Exception e) { |
System.out.println(e);
|
}
|
try { |
con.commit();
|
} catch (Exception e) { |
System.out.println(e);
|
}
|
try { |
con.rollback(sp);
|
} catch (Exception e) { |
System.out.println(e);
|
}
|
|
rs.close();
|
stmt.close();
|
con.close();
|
|
|
}
|
}
|