Is closing a ResulSet, Statement or connection act as a rollback when a transaction is not commited? Not clear in JavaDoc.

Поиск
Список
Период
Сортировка
От David Gagnon
Тема Is closing a ResulSet, Statement or connection act as a rollback when a transaction is not commited? Not clear in JavaDoc.
Дата
Msg-id 4266992B.2080901@siunik.com
обсуждение исходный текст
Ответ на Re: implementing asynchronous notifications  (David Gagnon <dgagnon@siunik.com>)
Ответы Re: Is closing a ResulSet, Statement or connection act as  (Oliver Jowett <oliver@opencloud.com>)
Список pgsql-jdbc
Hi all,

  I use the following code when accessing Postgreql.  I suspect it may
have a weakness if an exception (Not SQLException) is thrown in the
try/catch block.   I got a NullPointerException today so with the
following code there is no rollback on the trasaction but the
ResultSet/Connection/Statement will be closed (in finally block).  Is
that oki?  I will probably change the catch (SQLException e) for a catch
(Exception e).  I just wanted to be sure since it's not clear in the
javadoc that closing a uncomitted resultSet is the samething as issuing
a rollback prior to closing the ResultSet.

Thanks for your help!! It's really appreciated
/David

 try {
            dbCon = ConnectionFactory.getConnection();
            dbCon.startTransaction();

...
    Throws NullPointerException...

...
            dbCon.commitTransaction();
        } catch (SQLException e) {

            log.error("Problem with the db : " + e.getMessage(), e);
            try {
                dbCon.rollbackTransaction();
            } catch (SQLException e1) {
                log.error("Unable to rollback : " + e1.getMessage(), e);
            }
            ExceptionAdaptor.instance().getMappedException(e, "Unable to
add : " + e.getMessage(), true, ExceptionAdaptor.ACTION_INSERT);
        } finally {
            if (dbCon != null)
                dbCon.closeAll();
        }

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: David Gagnon
Дата:
Сообщение: Re: implementing asynchronous notifications
Следующее
От: Mike Heath
Дата:
Сообщение: JDBC locking on processResults