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:
None 
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
Description:
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:
@Test
public void test() throws SQLException {
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?user=user&password=password");
    Statement stmt = con.createStatement();
    stmt.setQueryTimeout(700000000);
    System.out.println(stmt.getQueryTimeout());
    try {
        stmt.executeUpdate("CREATE TABLE table0_0(id INT PRIMARY KEY,value VARCHAR(50));");
    } catch (Exception e) {
        System.out.println(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.

regards,
Umesh
[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."

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

Page generated in 0.051 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.