Bug #110325 executeBatch returns unexpected result

Submitted: 9 Mar 2023 13:16 Modified: 10 Mar 2023 9:47
Reporter: Wenqian Deng Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:8.0.32 OS:Any
Assigned to: CPU Architecture:Any

[9 Mar 2023 13:16] Wenqian Deng
Description:
When I executed the following test, I found that executeBatch() returned -1.
However, according to the JDBC docs, https://docs.oracle.com/javase/8/docs/api/java/sql/Statement.html#executeBatch--,the returned value should be >= 0 or SUCCESS_NO_INFO or EXECUTE_FAILED.

How to repeat:
@Test
public void mysqlBatchTest() {
    try {
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306?user=user&password=password&allowMultiQueries=true");
        Statement statement = con.createStatement();
        statement.execute("DROP DATABASE IF EXISTS test;");
        statement.execute("CREATE DATABASE test;");
        statement.execute("USE test;");
        statement.execute("CREATE TABLE t0(c0 SMALLINT NOT NULL);");

        statement.addBatch("REPAIR TABLE t0;");

        int[] res = statement.executeBatch();
        for (int r : res) {
            System.out.println(r);
        }
        statement.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
[10 Mar 2023 9:47] MySQL Verification Team
Hello mingshi wu,

Thank you for the report and test case.

regards,
Umesh
[20 Oct 2023 16:42] Filipe Silva
Bug#112213 is a duplicate.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.041 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.