Re: Using ON_ERROR_ROLLBACK functionality in JDBC

From: Kris Jurka <books(at)ejurka(dot)com>
To: "Koth, Christian \(DWBI\)" <Christian(dot)Koth(at)smiths-heimann(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Using ON_ERROR_ROLLBACK functionality in JDBC
Date: 2006-07-28 08:57:07
Message-ID: Pine.BSO.4.63.0607280353300.21507@leary2.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Fri, 28 Jul 2006, Koth, Christian (DWBI) wrote:

> I would need the same functionality using JDBC. So I could continue with
> my batch insert even if one or more statements fail. Right now I'm
> committing the transaction after each insert.
>
> I have thought of the following:
>
> 1. Checking constraints before calling insert. (to slow)
> 2. Creating a user defined savepoint before each insert,
> and rolling back to this savepoint if the insert fails. (not tried yet)
>
> What would you recommend? Is it possible to set ON_ERROR_ROLLBACK for
> JDBC transactions?

The JDBC driver does not currently support this behavior and if it did it
would implement it using 2) behind the scenes, so that's a good approach.

Also it's not clear what you mean by a batch, but the use of savepoints
will not allow things like Statement.executeBatch() to commit parts of a
batch. It's all or nothing for these.

Kris Jurka

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Koth, Christian (DWBI) 2006-07-28 09:51:12 Re: Using ON_ERROR_ROLLBACK functionality in JDBC
Previous Message Koth, Christian (DWBI) 2006-07-28 08:39:55 Using ON_ERROR_ROLLBACK functionality in JDBC