questions regarding transactions

From: Fabian Zeindl <fabian(at)xover(dot)htu(dot)tuwien(dot)ac(dot)at>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: questions regarding transactions
Date: 2007-07-11 20:32:57
Message-ID: 46953E79.5010204@xover.htu.tuwien.ac.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

I'm using JDBC with transactions and I've got a couple of questions:

1) Am I supposed to do "myConn.rollback()" on error? What happens if I
don't do it - will the transaction stay half-committed?! (I ask this,
because rollback() can throw a SQLException, so it's not guaranteed to
work, in my opinion).

2) When I use statements like (SELECT currval('somesequence')) in a
jdbc-transaction, will it be atomic to? Will the sequence be decremented
again when the transaction fails? Can I get wrong numbers, when there is
another transaction which increments somesequence?

3) Is it sufficient to do setAutocommit(false) and set the
transaction-level or do I have to call a statement like "START
TRANSACTION" to properly start an transaction? (I found
the latter example somewhere on the net.)

Many thanks in advance and thank you for the wonderful driver
fabian zeindl

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Heikki Linnakangas 2007-07-11 21:07:55 Re: questions regarding transactions
Previous Message Marcel Steinbach 2007-07-11 13:17:19 incomplete batch-updates