Bug #118163 A discovery that does not conform to the JDK specification
Submitted: 12 May 7:53 Modified: 19 May 5: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 7:53] 策 吕
Description:
I have identified that when executing certain non-DML SQL statements (e.g., DESC t0) via Statement.executeBatch(), the MySQL Connector/J driver returns -1 in the update-counts array. According to the JDBC specification, the only valid return values are:
    * A non-negative integer (number of rows affected)
    * Statement.SUCCESS_NO_INFO (-2)
    * Statement.EXECUTE_FAILED (-3) 
Source link: https://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html

How to repeat:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class test110325bugMO {
    public static void main(String[] args) throws SQLException {
        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 = null;
        con = DriverManager.getConnection(url1);
        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");
        statement.addBatch("DESC t0");

        int[] res = statement.executeBatch();
        for (int r : res) {
            System.out.println(r);
        }
        statement.close();
    }
}
[12 May 9:57] MySQL Verification Team
Hello 策 吕,

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

regards,
Umesh
[19 May 5:53] Axyoan Marcelo
Duplicate of Bug#110325