pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Altaf Malik <mmalik_altaf@yahoo.com>
To: James Im <im-james@hotmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: how to continue using a connection after an error with autocommit=false
Date: Tue, 20 Feb 2007 02:53:46 -0800 (PST)
Message-ID: <305445.70270.qm@web39109.mail.mud.yahoo.com> (raw)
In-Reply-To: <BAY7-F2720A1254B9177F763D58796890@phx.gbl>

You can either commit or rollback the transaction when you encounter an SQL error. This will alow the next statements to execute successfully. 
   
  --Altaf Malik
  EnterpriseDB
  www.enterprisedb.com

James Im <im-james@hotmail.com> wrote:
  Hi,

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
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1525)
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1309)
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:258)


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.

_________________________________________________________________
Vælg selv hvordan du vil kommunikere - skrift, tale, video eller billeder 
med MSN Messenger: http://messenger.msn.dk/ - her kan du det hele


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match


 
---------------------------------
Don't get soaked.  Take a quick peak at the forecast 
 with theYahoo! Search weather shortcut.

view thread (7+ messages)  latest in thread

Message-ID: <305445.70270.qm@web39109.mail.mud.yahoo.com>
Permalink:  ../305445.70270.qm@web39109.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/305445.70270.qm@web39109.mail.mud.yahoo.com

 · 

reply

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: mmalik_altaf@yahoo.com, im-james@hotmail.com
  Subject: Re: how to continue using a connection after an error with autocommit=false
  In-Reply-To: <305445.70270.qm@web39109.mail.mud.yahoo.com>
  References: <BAY7-F2720A1254B9177F763D58796890@phx.gbl> <305445.70270.qm@web39109.mail.mud.yahoo.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