Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id C67061337C00 for ; Tue, 29 Mar 2011 17:35:52 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 14907-01 for ; Tue, 29 Mar 2011 20:35:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from web33207.mail.mud.yahoo.com (web33207.mail.mud.yahoo.com [209.191.69.155]) by mail.postgresql.org (Postfix) with SMTP id 64DF81337C53 for ; Tue, 29 Mar 2011 17:34:33 -0300 (ADT) Received: (qmail 87461 invoked by uid 60001); 29 Mar 2011 20:34:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1301430871; bh=qEDD3Wairi7fXA8GH1E7er4DDNwxk3xYt7R0eYlCxdo=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:MIME-Version:Content-Type; b=eqAPmejrewanUr+YOvR/FQ6jDSDl1CF29SmxUcIdtntONQlCNirsmFTtB1kpTiaPyyjAit3wdrnMNeVuN0nbQfjKR/XrcvlUDI6qIJ+Jo19EBvRSOMSUBmTzEvfupyifb1QCAhGXziX6fauGFJf8D3fAvZBPXZyNBw/h9ufcr+k= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:MIME-Version:Content-Type; b=FJufwqjqpOQgFXDUR/ndlsoSisXvYRoNA/OhqQA4471urQRcUdxtujPPinuvhYPdSLDPGrwoOb0iIaK/ECaTtuZfzV/B8iluvVV8mbfuc4o6LmBDwAi7a7KUiH+r6FetWWqAZD30ZfeWQyDmkJowpARlIo0Q0zWBKkqVZVvmaVY=; Message-ID: <483657.70223.qm@web33207.mail.mud.yahoo.com> X-YMail-OSG: wvuOZjYVM1mNA3DoSal3mXqq385FkyKcubAaUwOmNnLzTbX s4qZT7lqxhLjqjAAWstRTNFj_2MMAG7IRTL22KRatkOIR0zSyVKivOYwbuNZ dwWV9eB4RQWRG1i8plxbBVgJXYCRNrm8lpTi.D6Ae9w88VNPG6aHzzSVmI8a R9GN3f588atd0AIODTG8BJQZ739qRjoJzsCf4doJ0TtaE0gk73D_uJBD6dqk PBLUbSSQLUN6k0JuD1x3C0bnVi_1WI__kBS3k1loYrcT3C6lXIpclgjH0Q0A eOTmbuW5T4m1YkgvmcFl1oan37ozfVz92jaogwOnERNj1bMzA5WxNit9vtPZ JzKame5PGqo4yVyRfWqoBn4GW.IAx00LRN_RiyxGpNCLTLcaxt6nQksc- Received: from [199.84.5.210] by web33207.mail.mud.yahoo.com via HTTP; Tue, 29 Mar 2011 13:34:31 PDT X-Mailer: YahooMailClassic/12.0.2 YahooMailWebService/0.8.109.295617 Date: Tue, 29 Mar 2011 13:34:31 -0700 (PDT) From: Quartz Subject: Re: JDBC gripe list To: Dave Cramer Cc: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1035647885-1301430871=:70223" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.907 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RFC_ABUSE_POST=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201103/114 X-Sequence-Number: 21669 --0-1035647885-1301430871=:70223 Content-Type: text/plain; charset=us-ascii 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 wrote: > From: Dave Cramer > Subject: Re: [JDBC] JDBC gripe list > To: "Quartz" > Cc: pgsql-jdbc@postgresql.org > Received: Tuesday, March 29, 2011, 4:17 PM > On Tue, Mar 29, 2011 at 3:29 PM, > Quartz > 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 > > > --0-1035647885-1301430871=:70223 Content-Type: text/html; charset=us-ascii
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
> >
>
--0-1035647885-1301430871=:70223--