Bug #112884 Setting a large timeout leads to errors when executing SQL.
Submitted: 30 Oct 2023 15:02 Modified: 15 Dec 2023 23:04
Reporter: Wenqian Deng Email Updates:
Status: Closed Impact on me:
Category:Connector / J Severity:S3 (Non-critical)
Version:8.1.0 OS:Any
Assigned to: CPU Architecture:Any

[30 Oct 2023 15:02] Wenqian Deng
In my test case, when I set a very large timeout value, it can be set successfully without throwing any error. However, when I use this timeout value to execute SQL, it throws a java.lang.IllegalArgumentException: Negative delay. 
I think that if there needs to be a limit on the timeout value, an error should be thrown at the time of executing setQueryTimeout, rather than not throwing an error and setting it as a negative value.

How to repeat:
public void test() throws SQLException {
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?user=user&password=password");
    Statement stmt = con.createStatement();
    try {
        stmt.executeUpdate("CREATE TABLE table0_0(id INT PRIMARY KEY,value VARCHAR(50));");
    } catch (Exception e) {
[30 Oct 2023 15:02] Wenqian Deng
change title
[24 Nov 2023 6:59] MySQL Verification Team
Hello Wenqian Deng,

Thank you for the report and test case.
Verified as described.

[15 Dec 2023 23:04] Daniel So
Posted by developer:
Added the following entry to the C/J 8.3.0 changelog: 

"Setting a very large value for query timeout caused an IllegalArgumentException when a query was executed. It was due to an integer overflow, which is now avoided by changing the timeout value's data type from Integer to Long."