Skip site navigation (1) Skip section navigation (2)

how to continue using a connection after an error with autocommit=false

From: "James Im" <im-james(at)hotmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: how to continue using a connection after an error with autocommit=false
Date: 2007-02-20 10:41:37
Message-ID: BAY7-F2720A1254B9177F763D58796890@phx.gbl (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

I just find out that I cannot continue using a connection when I use
autocommit=false and that an sql insert failed.

In pseudo code this is what I'd like to do:

1) create connection
2) set autocommit = false
3) do an insert that succeed
4) do an insert that fails
5) catch the SQLException (I don't do a rollback on purpose)
6) do a select with the same connection
7) do another insert
8) commit

Everything goes well until step (6). where I receive the following error:

ERROR: current transaction is aborted, commands ignored until end of
transaction block
Exception: org.postgresql.util.PSQLException

Can I do something is step (5) so that I don't get the error in step (6) ?
I need to continue using the same connection.

Thanks you your help.

Vlg selv hvordan du vil kommunikere - skrift, tale, video eller billeder 
med MSN Messenger:  - her kan du det hele


pgsql-jdbc by date

Next:From: James ImDate: 2007-02-20 10:48:43
Subject: invalid byte sequence for encoding "UTF8": 0x00
Previous:From: Robert SpiesDate: 2007-02-19 22:46:09
Subject: unsubscribe

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group