Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
3.3.1
-
None
Description
The bug involves a discrepancy in the behavior of the executeBatch method in JDBC applications using MariaDB and MySQL connectors. Specifically, when executeBatch encounters an error in executing its batch of SQL statements, the subsequent behavior of a repeated executeBatch call differs between MariaDB and MySQL. In MariaDB, the failed statements from the previous executeBatch call are re-executed, whereas in MySQL, they are not.
@Test
|
public void test() throws SQLException { |
Connection con;
|
Statement stmt;
|
ResultSet rs;
|
con = DriverManager.getConnection("jdbc:mariadb://localhost:3366/test1481?user=user&password=password"); |
stmt = con.createStatement();
|
stmt.execute("CREATE TABLE table1481_0(id TINYINT PRIMARY KEY,value SMALLINT);"); |
stmt.addBatch("INSERT INTO table1481_0 VALUES(1, 1)"); |
stmt.addBatch("INSERT INTO table1481_0 VALUES(1, 1)"); |
try { |
stmt.executeBatch();
|
} catch (BatchUpdateException e) { |
}
|
stmt.execute("TRUNCATE table1481_0;"); |
try { |
stmt.executeBatch();
|
} catch (Exception e) { |
}
|
rs = stmt.executeQuery("SELECT * FROM table1481_0"); |
while (rs.next()) { |
System.out.println(rs.getInt(1)); // mariadb : 1, mysql: empty |
}
|
}
|