pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
JDBC: "transaction aborted"
4+ messages / 4 participants
[nested] [flat]

* JDBC: "transaction aborted"
@ 2010-08-31 15:50  Pif <fjspam@laposte.net>
  0 siblings, 1 reply; 4+ messages in thread

From: Pif @ 2010-08-31 15:50 UTC (permalink / raw)
  To: pgsql-jdbc

Hello,

I use a connection pool (autocommit disabled). In some action servlet
of my website, I have "begin" and commit/rollback commands.
All work well.

But in my JSP page, when a select fail with JDBC exception, then I
cannot retry because of this exception :
"ERROR: current transaction is aborted, commands ignored until end of
transaction block"

So, since I only do select and I do not declare a begin statement, why
is there a transaction !? how can I choose that I don't want
transactions out of a begin/commit/roolback context !?

Thanks a lot.


PG 8.4



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: JDBC: "transaction aborted"
@ 2010-09-01 07:40  Fabien JALABERT <fabien.jalabert@laposte.net>
  parent: Pif <fjspam@laposte.net>
  0 siblings, 2 replies; 4+ messages in thread

From: Fabien JALABERT @ 2010-09-01 07:40 UTC (permalink / raw)
  To: pgsql-jdbc

Hello, if I turn on autocommit, will I be able to process transactions 
with begin/commit/rollback as before ?

Thanks.

Craig Ringer wrote:
>
> Turn autocommit on.
>
> -- 
> Craig Ringer
>
>




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: JDBC: "transaction aborted"
@ 2010-09-01 08:18  Craig Ringer <craig@postnewspapers.com.au>
  parent: Fabien JALABERT <fabien.jalabert@laposte.net>
  1 sibling, 0 replies; 4+ messages in thread

From: Craig Ringer @ 2010-09-01 08:18 UTC (permalink / raw)
  To: Fabien JALABERT <fabien.jalabert@laposte.net>; +Cc: pgsql-jdbc

On 01/09/10 15:40, Fabien JALABERT wrote:
> Hello, if I turn on autocommit, will I be able to process transactions
> with begin/commit/rollback as before ?

If you mean issuing explicit "BEGIN", "COMMIT" and "ROLLBACK" statements
as SQL text through the JDBC driver ... honestly, I'm not sure. It's not
really how the JDBC interface is intended to work.

Typically when using JDBC you would let the driver take care of this.
You call

  conn.setAutoCommit(false);

... to open a transaction. Any work between then and a subsequent:

  conn.commit()

or

  conn.rollback()

is done in the transaction.



-- 
Craig Ringer

Tech-related writing: http://soapyfrogs.blogspot.com/



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: JDBC: "transaction aborted"
@ 2010-09-01 08:26  Oliver Jowett <oliver@opencloud.com>
  parent: Fabien JALABERT <fabien.jalabert@laposte.net>
  1 sibling, 0 replies; 4+ messages in thread

From: Oliver Jowett @ 2010-09-01 08:26 UTC (permalink / raw)
  To: Fabien JALABERT <fabien.jalabert@laposte.net>; +Cc: pgsql-jdbc

Fabien JALABERT wrote:
> Hello, if I turn on autocommit, will I be able to process transactions
> with begin/commit/rollback as before ?

"Maybe" - but you shouldn't be doing that anyway. The JDBC model expects
that to do explicit transaction demarcation, you turn off autocommit and
use methods on Connection to do commit/rollback. You shouldn't be
issuing queries with explicit BEGIN/COMMIT/ROLLBACK.

see e.g.
http://download.oracle.com/javase/1.3/docs/guide/jdbc/getstart/connection.html#1004665

-O



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2010-09-01 08:26 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-08-31 15:50 JDBC: "transaction aborted" Pif <fjspam@laposte.net>
2010-09-01 07:40 ` Fabien JALABERT <fabien.jalabert@laposte.net>
2010-09-01 08:18   ` Craig Ringer <craig@postnewspapers.com.au>
2010-09-01 08:26   ` Oliver Jowett <oliver@opencloud.com>

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