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

Houx Zhang updated DERBY-4443:
------------------------------

    Attachment: DERBY-4443-6-tmp.patch

Hello, I have provided DERBY-4443-6-tmp.patch.

 private static void rollBackAndThrowSQLException(Connection conn,
            SQLException se) throws SQLException {
        try {
            conn.rollback();
        } catch (SQLException e) {
            se.setNextException(e);            
        }
        
        StandardException ste = StandardException.newException(
                se.getSQLState(), (Throwable)se);
        SQLException sqle = new SQLException((Throwable)ste); //this line can 
not pass compilation
        
        throw sqle;
    }

In rollBackAndThrowSQLException() of this patch, SQLException has been wrapped 
in StandardException, which is wrapped in another SQLException. However, the 
patch can not pass compilation, and says "constructor 
SQLException(java.lang.Throwable) can not be found". I'm puzzled about it. 
Please give an advice, thanks!

> 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-6-tmp.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