Description:
/*
* There's a MYSQL bug here, where setting allowMultiQueries to false results in -3 1
* but when allowMultiQueries is set to true, the result is -1 -3.
* This is confusing.
* Theoretically, allowMultiQueries=true or false should only affect whether or not multiple queries can be executed in the same Statement when executing a batch, and should not affect the results of individual queries.
* If the two result in significantly different behavior for batch results, this could indeed be a design issue or implementation bug in the JDBC driver.
* */
How to repeat:
public static void main(String[] args) throws SQLException
{
/*
* There's a MYSQL bug here, where setting allowMultiQueries to false results in -3 1
* but when allowMultiQueries is set to true, the result is -1 -3.
* This is confusing.
* Theoretically, allowMultiQueries=true or false should only affect whether or not multiple queries can be executed in the same Statement when executing a batch, and should not affect the results of individual queries.
* If the two result in significantly different behavior for batch results, this could indeed be a design issue or implementation bug in the JDBC driver.
* */
String url1 = "jdbc:mysql://localhost:3306/test?user=root&password=1234&allowMultiQueries=true";
String url2 = "jdbc:oceanbase://49.52.27.61:2881/test?user=root@test&password=1234&allowMultiQueries=true";
Connection con = DriverManager.getConnection(url1);
Statement stmt = con.createStatement();
stmt.execute("DROP TABLE IF EXISTS t0");
stmt.execute("CREATE TABLE t0(c0 INT PRIMARY KEY NOT NULL)");
stmt.execute("INSERT INTO t0 VALUES (267492252)");
Statement bstmt = con.createStatement();
bstmt.addBatch("INSERT INTO t0 VALUES (267492252)");
bstmt.addBatch("INSERT INTO t0 VALUES (622)");
try {
bstmt.executeBatch();
} catch (BatchUpdateException e) {
int[] res = e.getUpdateCounts();
for (int r : res) {
System.out.println(r);
}
}
}