From: Oliver Jowett <oliver@opencloud.com>
To: Philip Yarra <philip@utiba.com>
Cc: Dave Cramer <pg@fastcrypt.com>
Cc: Amaresh Wakkar <babu_moshay@indiatimes.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: 25P02, current transaction is aborted, commands ignored
Date: Mon, 03 Apr 2006 01:03:26 +0000
Message-ID: <4430745E.2000001@opencloud.com> (raw)
In-Reply-To: <44306FD9.1040905@utiba.com>
References: <200604021130.RAA11482@WS0005.indiatimes.com>
<9B9703A9-2B17-4485-A035-D0DEF68C9932@fastcrypt.com>
<44306FD9.1040905@utiba.com>
Philip Yarra wrote:
> I always assumed what Dave just said, but porting from Oracle & Sybase
> to PostgreSQL, we ran into exactly the same issue - we also solved it
> with savepoints. However, I threw together the attached sample app to
> test *precisely* what ends up in the database when auto-commit is off.
> For the impatient, it sets auto-commit off, and tries to insert 3 rows.
> The first succeeds, the second violates a unique index, so fails, and
> the third is issued after the second, so should also fail. We ignore the
> exceptions, then commit. The results puzzle me somewhat:
> static void executeInsert(int id, String msg)
> {
> log("executeInsert, id[" + id + "] msg[" + msg + "]");
> PreparedStatement stmt = null;
> try{
> stmt = conn.prepareStatement("INSERT INTO tempextest(id,msg) VALUES(?,?)");
> stmt.setInt(1,id);
> stmt.setString(2,msg);
> stmt.executeUpdate();
> conn.commit();
> } catch (SQLException sqlex) {
> log(sqlex);
> closeStatement(stmt);
> }
> }
Um, your testcase is committing after every insert, not once at the end.
So the behaviour you see sounds correct.
-O
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: oliver@opencloud.com, philip@utiba.com, pg@fastcrypt.com, babu_moshay@indiatimes.com
Subject: Re: 25P02, current transaction is aborted, commands ignored
In-Reply-To: <4430745E.2000001@opencloud.com>
References: <200604021130.RAA11482@WS0005.indiatimes.com> <9B9703A9-2B17-4485-A035-D0DEF68C9932@fastcrypt.com> <44306FD9.1040905@utiba.com> <4430745E.2000001@opencloud.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox