You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2007/05/24 11:24:16 UTC

[jira] Updated: (DERBY-1440) jdk 1.6 client driver omits SQLStates and chained exceptions in error messages

     [ https://issues.apache.org/jira/browse/DERBY-1440?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-1440:
--------------------------------------

    Attachment: 1440.stat
                1440.diff

While working on DERBY-2472 I found out what caused this difference between the JDBC 3.0 driver and the JDBC 4.0 driver. There are three problems. Firstly, StandardException.unexpectedUserException() doesn't recognize that an SQLException is generated Derby since it is not an EmbedSQLException. Secondly, TransactionResourceImpl.wrapInSQLException() invokes SQLException.setNextException() explicitly so that the required chaining/ferrying logic in the exception factory and in EmbedSQLException's constructor is not used. Thirdly, SQLException40.wrapArgsForTransportAcrossDRDA() puts a standard SQLException, not an EmbedSQLException, in the argument ferry's next-exception chain, which prevents the network server from seeing it as a Derby exception.

The attached patch fixes the problem by
  1) using SQLExceptionFactory.getArgumentFerry() to find out whether the exception is a Derby exception in unexpectedUserException()
  2) using factory methods instead of setNextException() to do the chaining in wrapInSQLException()
  3) improving Util.javaException() so that it sets up a next-exception chain if the Java exception contains nested exceptions
  4) changing wrapArgsForTransportAcrossDRDA() to create an argument ferry whose next exception is the argument ferry of the main exception's next exception

This patch also fixes all the JUnit tests that contain code looking like this:

    assertStatementError(JDBC.vmSupportsJDBC4() ? "38000" : "42X62", cSt);

Now, the check for JDBC level is not needed anymore for those tests.

Derbyall and suites.All ran cleanly on Java 1.5 and Java 1.6.

> jdk 1.6 client driver omits SQLStates and chained exceptions in error messages
> ------------------------------------------------------------------------------
>
>                 Key: DERBY-1440
>                 URL: https://issues.apache.org/jira/browse/DERBY-1440
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC, Network Client, Tools
>    Affects Versions: 10.2.1.6
>         Environment: Sun JDK 1.6
>            Reporter: Olav Sandstaa
>         Assigned To: Knut Anders Hatlen
>            Priority: Minor
>         Attachments: 1440.diff, 1440.stat
>
>
> When running some SQL queries through ij that fails it seems like some
> information about chained exceptions is not presented to the user when
> running with the client driver and jdk 1.6.
> One example SQL that fails (taken from the ieptests.sql):
> =========================================================
> ij> call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('inventory', 'ORDERTABLE' ,
> 'extinout/order.dat', null, null, null) ;
> When running this in ij the following error message is produced:
> Java 1.6 Embedded driver:
> =========================
> ERROR 38000: The exception 'java.sql.SQLSyntaxErrorException: Schema
> 'inventory' does not exist' was thrown while evaluating an expression.
> ERROR 42Y07: Schema 'inventory' does not exist
> Java 1.5 Client driver:
> =======================
> ERROR 38000: The exception 'SQL Exception: Schema 'inventory' does not
> exist' was thrown while evaluating an expression. SQLSTATE: 42Y07:
> Schema 'inventory' does not exist
> Java 1.6 Client driver:
> =======================
> ERROR 38000: The exception 'java.sql.SQLSyntaxErrorException: Schema
> 'inventory' does not exist' was thrown while evaluating an expression.
> The bug (or difference) here is that the client driver when running
> with jdk 1.6 does not print the chained exception and SQL state.
> It would be nice to have the same information in the output as what is
> written by the embedded driver (or client driver running with jdk
> 1.5).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.