Issue Details (XML | Word | Printable)

Key: DERBY-1991
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Knut Anders Hatlen
Reporter: Knut Anders Hatlen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Misleading stack traces for exceptions raised by the JDBC 4.0 embedded driver

Created: 24/Oct/06 07:20 AM   Updated: 31/Oct/06 08:45 AM
Return to search
Component/s: JDBC
Affects Version/s: 10.2.1.6
Fix Version/s: 10.2.2.0, 10.3.1.4

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works derby-1991.diff 2006-10-24 07:26 AM Knut Anders Hatlen 4 kB
Text File Licensed for inclusion in ASF works derby-1991.stat 2006-10-24 07:26 AM Knut Anders Hatlen 0.3 kB
Environment: Java SE 6, Derby with JDBC 4.0 compiled in.

Resolution Date: 31/Oct/06 08:45 AM


 Description  « Hide
When the embedded driver raises an SQLException, its stack trace always
says it is created in SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA().
This is not correct.

At some point, SQLExceptionFactory40.getSQLException() set the stack trace
of the SQLException to the stack trace of the non-SQLException that caused
it, if there were one. This was probably done to mimic the behaviour of
EmbedSQLException, which overrides printStackTrace() to achieve the
same. Later, code was added to ferry arguments over DRDA. This code created
a dummy exception which the old code interpreted as a non-SQLException
whose stack trace should be used for the main exception. Therefore, all
exceptions now have the same stack trace as the dummy exception created in
wrapArgsForTransportAcrossDRDA().

I think the best solution is not to set the stack trace explicitly, not
even when the SQLException is caused by a non-SQLException.
EmbedSQLException overrides printStackTrace() because throwables in Java
1.3 didn't have initCause()/getCause(), so it was the only way to preserve
the original stack trace. Since the SQLExceptions in JDBC 4.0 have
initCause()/getCause(), there is no reason why the JDBC4 driver should
mimic EmbedSQLException's workaround for not having these methods.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #469410 Tue Oct 31 08:28:26 UTC 2006 kahatlen DERBY-1991: Misleading stack traces for exceptions raised by the JDBC
4.0 embedded driver

Don't set the stack trace of the SQLException to the stack trace of
the dummy exception in SQLExceptionFactory40.
Files Changed
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk16/closed.out
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk16/releaseCompileLocks.out
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java

Repository Revision Date User Message
ASF #469415 Tue Oct 31 08:44:27 UTC 2006 kahatlen DERBY-1991: Misleading stack traces for exceptions raised by the JDBC
4.0 embedded driver

Merged fix from trunk (svn merge -r 469409:469410 ../trunk).
Files Changed
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/jdk16/releaseCompileLocks.out
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/jdk16/closed.out
MODIFY /db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java