pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: dmp <danap@ttc-cmc.net>
To: Haifeng Liu <liuhaifeng@live.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)
Date: Fri, 14 Dec 2012 09:30:50 -0700
Message-ID: <50CB543A.3020005@ttc-cmc.net> (raw)
In-Reply-To: <BLU0-SMTP1534C0E74C7BF8FD348BE51B94D0@phx.gbl>
References: <BLU0-SMTP1143B3C57133A122263A47AB94E0@phx.gbl>
	<BLU0-SMTP23378AE609963CCB543ED38B94D0@phx.gbl>
	<50CB4C40.7000104@ttc-cmc.net>
	<BLU0-SMTP1534C0E74C7BF8FD348BE51B94D0@phx.gbl>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

Hello,

Perhaps you should pose the question to the server mailing list. It seems that
maybe the sequence is possibly being changed in execution. In a small update,
10, the sequence stays intact, but for a larger update the server perhaps is
optimizing the sequence for execution thereby changing the order. In any case
you appeared to answer your own question.

http://archives.postgresql.org/pgsql-general/

danap.

Haifeng Liu wrote:
> example code:
>
> Connection conn = getConnection();
> PreparedStatement pstmt = conn.prepareStatement("insert/update...");
> for (A a : AList) {
> 	pstmt.setParameter(...);
> 	pstmt.addBatch();
> }
> pstmt.executeBatch();
>
> I did a simple test and found that if one of the batch failed, the other update may be execute partially. when I test with 10 updates a batch, none of them are updated, when I test with 1000 updates a batch, about 700+ of them are executed, but the failed update should be the last one, which means 999 executed updates is more reasonable than 700+. But really weird thing is the getUpdateCounts method returns the reasonable information.
>
> I don't know what happened inside this driver. Currently I have to setAutoCommit to false and use commit/rollback to achieve my goal.
>
>
> On Dec 14, 2012, at 11:56 PM, dmp<danap@ttc-cmc.net>  wrote:
>
>> Hello,
>>
>> Though a simple example of your code would provide a better response
>> from the mailing list, I will speculate based on the context of the
>> Java 6 API, statement class and your comments. Yes, the batch appears
>> to be proceeding.


-- 
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 (9+ messages)  latest in thread

Message-ID: <50CB543A.3020005@ttc-cmc.net>
Permalink:  ../50CB543A.3020005@ttc-cmc.net/
Also on:    postgresql.org/message-id/50CB543A.3020005@ttc-cmc.net

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: danap@ttc-cmc.net, liuhaifeng@live.com, pgsql-jdbc@postgresql.org
  Subject: Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)
  In-Reply-To: <50CB543A.3020005@ttc-cmc.net>

* 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