pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Quartz <quartz12h@yahoo.com>
To: Dave Cramer <pg@fastcrypt.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: JDBC gripe list
Date: Tue, 29 Mar 2011 13:34:31 -0700 (PDT)
Message-ID: <483657.70223.qm@web33207.mail.mud.yahoo.com> (raw)

Keep reading:
http://download.oracle.com/javase/6/docs/api/java/sql/Statement.html#executeBatch%28%29

"If one of the commands in a batch update fails to execute properly, this method throws a BatchUpdateException, and a JDBC driver may or may not continue to process the remaining commands in the batch. However, the driver's behavior must be consistent with a particular DBMS, either always continuing to process commands or never continuing to process commands. If the driver continues processing after a failure, the array returned by the method BatchUpdateException.getUpdateCounts will contain as many elements as there are commands in the batch, and at least one of the elements will be the following[...]"

"The possible implementations and return values have been modified in the Java 2 SDK, Standard Edition, version 1.3 to accommodate the option of continuing to proccess commands in a batch update after a BatchUpdateException obejct has been thrown. "

For those who believe the driver is fine when breaking the batch after the 1st error, then in my example of 5 inserts with pk id=1 to 5 (with id 2 and 4 already present) the table won't contain at least the id=1 (which didn't fail).

The postgres driver is partly at fault, but the server is too, for making a transaction whene there is none. Try to get any of the 2 sides to work on it and they just throw the problem the other way:
"[server guys]: oh its a driver issue then!..." 
"[driver guys]: oh, its a server issue then!..."
Nothing gets done, and we are stuck.



--- On Tue, 3/29/11, Dave Cramer <pg@fastcrypt.com> wrote:

> From: Dave Cramer <pg@fastcrypt.com>
> Subject: Re: [JDBC] JDBC gripe list
> To: "Quartz" <quartz12h@yahoo.com>
> Cc: pgsql-jdbc@postgresql.org
> Received: Tuesday, March 29, 2011, 4:17 PM
> On Tue, Mar 29, 2011 at 3:29 PM,
> Quartz <quartz12h@yahoo.com>
> wrote:
> > addBatch()/executeBatch() is broken under
> autocommit=true.
> >
> > Every statement is clearly supposed to be
> independant.
> > Example: 5 insert statements, let's say the 2th and
> the 4th are on duplicate of primary key. All 3 others should
> still be performed but they aren't.
> >
> > This breaks our application. We migrated from mysql,
> and BOOM...
> >
> 
> I would think the concept of execute batch would infer that
> they
> should all commit or none should. This line from the API
> seems to
> infer that
> 
> "Submits a batch of commands to the database for execution
> and if all
> commands execute successfully, returns an array of update
> counts."
> 
> Where it states "if all commands execute successfully"
> implies a
> transaction in the postgresql world.
> 
> Dave
> 
> >
> > --
> > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgsql-jdbc
> >
> 

view thread (65+ messages)  latest in thread

Message-ID: <483657.70223.qm@web33207.mail.mud.yahoo.com>
Permalink:  ../483657.70223.qm@web33207.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/483657.70223.qm@web33207.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: quartz12h@yahoo.com, pg@fastcrypt.com
  Subject: Re: JDBC gripe list
  In-Reply-To: <483657.70223.qm@web33207.mail.mud.yahoo.com>
  References: <483657.70223.qm@web33207.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