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

From: dmp <danap(at)ttc-cmc(dot)net>
To: Haifeng Liu <liuhaifeng(at)live(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)
Date: 2012-12-14 16:30:50
Message-ID: 50CB543A.3020005@ttc-cmc.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general 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 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(at)ttc-cmc(dot)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.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Haifeng Liu 2012-12-14 16:50:08 Fwd: [JDBC] Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)
Previous Message Haifeng Liu 2012-12-14 16:25:23 Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)

Browse pgsql-general by date

  From Date Subject
Next Message Haifeng Liu 2012-12-14 16:50:08 Fwd: [JDBC] Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)
Previous Message joshua 2012-12-14 16:26:54 Re: Implicit casts to array types

Browse pgsql-jdbc by date

  From Date Subject
Next Message Haifeng Liu 2012-12-14 16:50:08 Fwd: [JDBC] Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)
Previous Message Haifeng Liu 2012-12-14 16:25:23 Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)