Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc) - Mailing list pgsql-jdbc

From dmp
Subject Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)
Date
Msg-id 50CB543A.3020005@ttc-cmc.net
Whole thread Raw
In response to Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)  (Haifeng Liu <liuhaifeng@live.com>)
List pgsql-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
with10 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+.
Butreally 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
achievemy 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.


pgsql-jdbc by date:

Previous
From: Haifeng Liu
Date:
Subject: Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)
Next
From: Kris Jurka
Date:
Subject: Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)