Re: JDBC gripe list (the autocommit subthread) - Mailing list pgsql-jdbc

From Quartz
Subject Re: JDBC gripe list (the autocommit subthread)
Date
Msg-id 638011.77546.qm@web33205.mail.mud.yahoo.com
Whole thread Raw
In response to Re: JDBC gripe list (the autocommit subthread)  (Jeff Hubbach <Jeff.Hubbach@cha.com>)
List pgsql-jdbc
Please don't refer to old docs/specs.
I posted latest docs previously.



--- On Thu, 3/31/11, Jeff Hubbach <Jeff.Hubbach@cha.com> wrote:

From: Jeff Hubbach <Jeff.Hubbach@cha.com>
Subject: Re: [JDBC] JDBC gripe list (the autocommit subthread)
To: "pgsql-jdbc@postgresql.org" <pgsql-jdbc@postgresql.org>
Received: Thursday, March 31, 2011, 6:02 PM

On Mar 31, 2011, at 3:34 PM, Quartz wrote:


Besides that's what release notes are for. And I dare say, if they expected a transaction when using a batch with autocommit=true, it about time they learn their mistake. JDBC api is a contract. Can't make exception for postgres.


Quartz, the problem is that behavior of batch updates when autocommit=true is not spec-defined, it's implementation-defined. Just because MySQL does it one way doesn't make that the "right" way. Look at this post from 2009:
"The behavior after a failure is DBMS specific, as documented in Statement.executeBatch(). Some unit tests I've run had shown that MSSQL continues with the rest of the statements while Oracle aborts the batch immediately."

And reading through the JDBC guide, albeit for an older version, here:
states
"For this reason, autocommit should always be turned off when batch updates are done. The commit behavior of executeBatch is always implementation defined when an error occurs and autocommit is true."

And from the most recent JDBC tutorial, here:
"To allow for correct error handling, you should always disable auto-commit mode before beginning a batch update."

It seems to me that this is a case of you expecting behavior that is not spec-defined, but because your prior experience with MySQL has taught you to expect certain behavior, you expect that behavior to also be present in other drivers even though the spec does not clearly state the expected behavior (it explicitly states that it's implementation-defined). This is clear in the first post I linked to, where MSSQL continues (as does MySQL from your admission), but Oracle aborts.

-- Jeff Hubbach

pgsql-jdbc by date:

Previous
From: Daron Ryan
Date:
Subject: Re: PreparedStatement with ANY
Next
From: Quartz
Date:
Subject: Re: JDBC gripe list (the autocommit subthread)