Description:
When allowMultiQueries=true is set in the connection URL, the getUpdateCount() method returns -1 after executing a batch of update and delete statements. In contrast, when allowMultiQueries=false (or not set), getUpdateCount() returns 0 under the same conditions.
The expected behavior is that the return value of getUpdateCount() should be consistent regardless of the allowMultiQueries setting, especially when no rows are affected by the executed statements.
How to repeat:
@Test
public void test() throws SQLException {
Connection con = null;
Statement stmt = null;
con = DriverManager.getConnection("jdbc:mysql://localhost:3366/test5?user=user&password=password&allowMultiQueries=true");
stmt = con.createStatement();
stmt.executeUpdate("CREATE TABLE table343_0(id INT PRIMARY KEY,value TEXT(5));", 2);
stmt = con.createStatement();
stmt.addBatch("UPDATE table343_0 SET value = 'U8cuL9jRqqj1#wT*Dw8o3JuYQL6%$I#lBB1r1V&3x' WHERE id >= 741449035");
stmt.addBatch("DELETE FROM table343_0 WHERE id <= -1946432626");
stmt.addBatch("DELETE FROM table343_0 WHERE id <= -1749798027");
stmt.executeBatch();
System.out.println(stmt.getUpdateCount()); // -1 if allowMultiQueries
}