[ 
https://issues.apache.org/jira/browse/DERBY-4443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014032#comment-13014032
 ] 

Houx Zhang commented on DERBY-4443:
-----------------------------------

Thanks for your checking, Knut.

This problem has perplexed me for some days. After checking again, I accept 
that 

    private static void rollBackAndThrowSQLException(Connection conn,
            SQLException se) throws SQLException {
        try {
            conn.rollback();
        } catch (SQLException e) {
            se.setNextException(e);
        }
        
        throw se;
    }

is better, we will get the full SQLException chain. However, it's very strange 
that when debugging in this situation, the chain will be broken down before 
thrown to EmbedPreparedStatement.executeUpdate() in Line 309 of 
EmbedPreparedStatement, and the rollback exception will be lost.


Is this situation normal, or is there something special for SQLException 
launched by rollback(), please?



> Wrap rollback in exception handlers in try-catch
> ------------------------------------------------
>
>                 Key: DERBY-4443
>                 URL: https://issues.apache.org/jira/browse/DERBY-4443
>             Project: Derby
>          Issue Type: Bug
>          Components: Demos/Scripts, Documentation, Eclipse Plug-in, JDBC, 
> Network Client, Network Server, Replication, Services, SQL, Test, Tools
>    Affects Versions: 10.5.3.0
>            Reporter: Aaron Digulla
>            Assignee: Houx Zhang
>              Labels: derby_triage10_8
>         Attachments: DERBY-4443-1.patch, DERBY-4443-2.patch, 
> DERBY-4443-3.patch, DERBY-4443-4.patch, DERBY-4443-4.png, DERBY-4443-5.patch, 
> DERBY-4443.patch
>
>
> Avoid this pattern everywhere:
>               }catch(SQLException se){
>                       //issue a rollback on any errors
>                       conn.rollback();
>                       throw  se;
>               }
> because an error in rollback will shadow the original exception.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to