commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Maciek Siemczyk (JIRA)" <>
Subject [jira] [Commented] (DBUTILS-112) Provide DbUtils.rollbackQuietly() method
Date Wed, 04 May 2016 21:02:12 GMT


Maciek Siemczyk commented on DBUTILS-112:

I would like to second adding this. I don't think this library should dictate how we structure
our code and therefore there is a need for rollbackQueitly().

For example our code is structured similarly to this:

try {
 try (PreparedStatement selectStatement = readDbConnection.prepareStatement();
      PreparedStatement insertStatement = writeDbConnection.prepareStatement()) {
    // bunch of code in here
    } catch (SQLException exception) {
        final String message = "Database error occured during XXXXX.";
        try {
        } catch (SQLException rollbackException) {

        log.error(message, exception);
        throw new SQLException(message, exception);
} finally {

The way code is structured the null is not possible writeDbConnection on the catch block,
but I also don't care if rollback failed as we are exiting anyways. So instead of wrapping
rollback everywhere I would prefer to call DbUtils.rollbackQuietly() even for the sake of
improving code coverage it is worth in my opinion.

I modified your code myself and will be adding patch for it shortly. I hope this can be included
in 1.7 release.

> Provide DbUtils.rollbackQuietly() method
> ----------------------------------------
>                 Key: DBUTILS-112
>                 URL:
>             Project: Commons DbUtils
>          Issue Type: Wish
>    Affects Versions: 1.5
>            Reporter: alexander brack
>            Priority: Trivial
>              Labels: features
>             Fix For: 1.7
>   Original Estimate: 5m
>  Remaining Estimate: 5m
> One has to surround DbUtils.rollback(conn) method-call with try/catch wich produces cluttered
code. Connection has to remain open, that's why DbUtils.rollbackAndCloseQuietly(conn) method
is ruled out.

This message was sent by Atlassian JIRA

View raw message