Bug #34321 Connector/J should use standard exceptions
Submitted: 5 Feb 2008 18:30 Modified: 29 May 2008 17:04
Reporter: Keywan Ghadami Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.5 OS:Any
Assigned to: CPU Architecture:Any

[5 Feb 2008 18:30] Keywan Ghadami
Description:
MySQLIntegrityConstraintViolationException does not extend
SQLIntegrityConstraintViolationException

How to repeat:
try {
  statement.exicute("insert with duplicate key");
} catch (SQLIntegrityConstraintViolationException e) {
 //!!!!!!!!!!!!! never reached !!!!!!!!!!!!
} catch (SQLException) {
 //no vendor independ way of getting the reason
}

Suggested fix:
Use standart exceptions and delete all unnecessary MySQL...Exceptions
or use Interfaces:

public class MySQLIntegrityConstraintViolationException extends
		SQLIntegrityConstraintViolationException implements MySQLNonTransientException {
 //...
}
[5 Feb 2008 18:57] Mark Matthews
Thanks for the bug report. 

We've got a way to fix this, but we can't delete the exceptions (because the driver supports both JDBC-3.0 and JDBC-4.0 interfaces at the same time), and we can't use interfaces. We'll just have to fix our factory that hands out the exceptions to use the JDBC-4.0 specific integrity constraint violation exception when it is running in Java6 or newer.
[29 May 2008 17:04] Keywan Ghadami
Thank you! Version 5.1.6 is working well.
[30 May 2008 6:56] Tonci Grgin
Keywan, glad the problem is solved.

Thanks for your interest in MySQL!