Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDBC 4.0 compliant Exception chaining [JDBC139] #180

Closed
firebird-automations opened this issue May 17, 2009 · 14 comments
Closed

JDBC 4.0 compliant Exception chaining [JDBC139] #180

firebird-automations opened this issue May 17, 2009 · 14 comments

Comments

@firebird-automations
Copy link

Submitted by: @mrotteveel

Attachments:
FBSQLException-patch.txt

Jaybird currently does not conform to JDBC 3.0 / JDBC 4.0 in respect to Exception chaining, and uses it's own method of chaining.

For JDBC 3.0 conformance, exception chaining using setNextException() / getNextException() should be implemented as specified in paragraph 8.1 of the JDBC 3.0 specification (these methods should only accept and return SQLException and descendants)

For JDBC 4.0 conformance, the Java 1.4 cause facility (exception chaining) as described in http://java.sun.com/javase/6/docs/api/java/lang/Throwable.html should be implemented and the exception chaining defined in JDBC 3.0 has been enhanced, see paragraph 8.1 in the JDBC 4.0 specification.
This enhancement includes navigation of the SQLExceptions and their causes using an iterator that returns SQLExceptions in order (as also defined by getNextException), including the Throwable chain defined by getCause(). See also http://java.sun.com/javase/6/docs/api/java/sql/SQLException.html

Implementing JDBC 4.0 should be enough to also result in JDBC 3.0 conformance.

JDBC specifications: http://java.sun.com/products/jdbc/download.html

Commits: 137db3e 36f0cc9 2ebf669

@firebird-automations
Copy link
Author

Modified by: Roman Rokytskyy (rrokytskyy)

Fix Version: Jaybird 2.2 [ 10053 ]

timeestimate: 0 [ 0 ]

timeoriginalestimate: 0 [ 0 ]

@firebird-automations
Copy link
Author

Commented by: Roman Rokytskyy (rrokytskyy)

Seems that we can fix it with simply deprecating the getInternalError() method and returning the original exception as the cause. Can you please confirm this or provide a test case against which the driver can be checked?

@firebird-automations
Copy link
Author

Modified by: Roman Rokytskyy (rrokytskyy)

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

I will see if I can look into this in the coming week.

@firebird-automations
Copy link
Author

Commented by: Roman Rokytskyy (rrokytskyy)

A test case would be great!

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

I have looked over the code and it looks OK to me. I have not created a testcase. instead I propose a patch which will greatly simplify FBSQLException and delegates more to the SQLException superclass and Throwable (obviating the need for a Firebird specific testcase as the behavior will be general Java). See the attached patch file.

What the patch does:
* Removes storing exception message in FBSQLException (delegate to superclass)
* Removes storing cause (original) in FBSQLException (delegate to superclass)
* Removes IOException specific constructor as it does not add any value (except adding 'I/O Exception ' to the message)
* Removes text 'Exception . ' from message text in (Exception ex) constructor
* Inherit (fb)errorcode in (GDSException ex) constructor
* Inherit errorcode in (String message, SQLException ex) constructor
* Remove setNextException in (String message, SQLException ex) constructor as it conflicts with the intent of the chaining (get/setNextException) : providing a way of communicating concurrent, but separate exceptions (or 'chain of events leading up to the final error')
* Remove getErrorCode() override (delegate to superclass)

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Attachment: FBSQLException-patch.txt [ 11582 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Reopen to integrate patch

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

assignee: Roman Rokytskyy [ rrokytskyy ] => Mark Rotteveel [ avalanche1979 ]

status: Resolved [ 5 ] => Reopened [ 4 ]

resolution: Fixed [ 1 ] =>

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Reopened [ 4 ] => In Progress [ 3 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Committed patch and some additional improvements to delegate more to superclass.

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: In Progress [ 3 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Missed two cases were the isc errorcode should be set. Committed correction.

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment