Bug #118234 A potential bugs in Mysql Connector/J
Submitted: 21 May 3:59 Modified: 21 May 7:03
Reporter: 策 吕 Email Updates:
Status: Verified 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

[21 May 3:59] 策 吕
Description:
The program runs normally when allowMultiQueries=true is used, and throws an exception when allowMultiQueries=true is not used or when allowMultiQueries=false is used.Theoretically adding &allowMultiQueries configuration or not should not affect the outcome of the program.

How to repeat:
import java.sql.*;

public class test {
    public static void main(String[] args) throws SQLException {
        String url1 = "jdbc:mysql://localhost:3306/test?user=root&password=1234";
        Connection con = null;
        Statement stmt = null;
        con = DriverManager.getConnection(url1);
        stmt = con.createStatement();

        stmt.executeUpdate("DROP TABLE IF EXISTS table0;");
        stmt.executeUpdate("CREATE TABLE table0(id INT PRIMARY KEY);");

        stmt.addBatch("DESC table0;");

        stmt.executeBatch();

    }

}
[21 May 7:03] MySQL Verification Team
Hello 策 吕,

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

regards,
Umesh
[16 Jul 19:19] Axyoan Marcelo
Posted by developer:
 
Hi 策 吕,

Thank you for your report. If you look at the documentation for Statement.executeBatch it states:

`Throws BatchUpdateException(a subclass of SQLException) if one of the commands sent to the database fails to execute properly or attempts to return a result set.`

The batch you are trying to execute contains the query "DESC table0;" which returns a ResultSet. BatchedStatements are meant to be used for update queries, such as INSERT or UPDATE. That said, the program is failing to throw an exception and this needs to be fixed. Thank you for bringing this to our attention.

Regards,
Axyoan