Bug #71589 MySQLTimeoutException must extend standard JDBC SQLTimeoutException

Submitted: 5 Feb 2014 5:04 Modified: 23 Jul 2021 13:01
Reporter: constantine Linnick Email Updates:
Status: Unsupported Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Filipe Silva CPU Architecture:Any
Tags: exception, java, timeout

[5 Feb 2014 5:04] constantine Linnick
Description:
If we use multiple connectors we cannot use standard sql exceptions to react unified way without vendor-specific classes

How to repeat:
// Create loooooong sql query
try{
Connection connection = getConnection(externalDataSource);
Statement st = connection.createStatement();
st.setQueryTimeout(timeout);
}catch(SQLTimeoutException){
    // we do not get here after timeout
}

Suggested fix:
MySQLTimeoutException extends SQLTimeoutException
[5 Feb 2014 10:24] Filipe Silva
Hi Constantine,

Thank you for this bug report. Verified by code review.
[25 Jun 2015 20:44] Ross Lamont
In Connector/J 5.1.35, PreparedStatement:1931 - throws a hard coded MySQLTimeoutException - should be doing Util.isJdbc4() somewhere.

Also - checkout MySQLStatementCancelledException - same problem
[23 Jul 2021 13:01] Alexander Soklakov
Posted by developer:
 
This bug does not affect MySQL Connector/J 8.0, com.mysql.cj.jdbc.exceptions.MySQLTimeoutException extends java.sql.SQLTimeoutException there.

MySQL Connector/J 5.1 series came to EOL on Feb 9th, 2021, see https://www.mysql.com/support/eol-notice.html, so this bug will not be fixed for this version.
[4 Jan 2023 22:40] Erica Kane
I have this same problem with version 8.0.27. For which version has this been fixed?
[5 Jan 2023 10:55] Filipe Silva
Hi Erica,

Please provide details.

In MySQL Connector/J 8.0 both MySQLTimeoutException and MySQLStatementCancelledException extend the right JDBC exceptions. This issue was only observable in Connector/J 5.1 where the JDBC 4 additions were implemented differently.

See also: https://github.com/mysql/mysql-connector-j/blob/release/8.0/src/main/user-impl/java/com/my...

And: https://github.com/mysql/mysql-connector-j/blob/release/8.0/src/main/user-impl/java/com/my...
[8 Jan 2023 13:41] Erica Kane
Yes I did see the extension appeared to be correct. There may be something else going on in our more complex system. You may ignore my earlier comment, thank you for responding.

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

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