Bug #118167 A potential bugs in Mysql Connector/J
Submitted: 12 May 10:59 Modified: 16 Jul 19:53
Reporter: 策 吕 Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:9.0.0, 9.3.0 OS:Any
Assigned to: CPU Architecture:Any

[12 May 10:59] 策 吕
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);
            }
        }
    }
[12 May 13:02] MySQL Verification Team
Hello 策 吕,

Thank you for the report and feedback.
Verified as described.

regards,
Umesh
[16 Jul 19:53] Axyoan Marcelo
The root cause of this bug is the same as Bug#118201 so this will be marked as a duplicate