Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TjYOK-0004aR-5N for pgsql-jdbc@arkaria.postgresql.org; Fri, 14 Dec 2012 16:45:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TjYOJ-0003gq-Bx for pgsql-jdbc@arkaria.postgresql.org; Fri, 14 Dec 2012 16:45:39 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TjYOI-0003gh-Qu for pgsql-jdbc@postgresql.org; Fri, 14 Dec 2012 16:45:38 +0000 Received: from outbound.vnet-inc.com ([216.146.104.103]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TjYO7-0000gt-E5 for pgsql-jdbc@postgresql.org; Fri, 14 Dec 2012 16:45:37 +0000 Received: from [192.168.157.132] (unknown [76.75.27.41]) by outbound.vnet-inc.com (Postfix) with ESMTP id 364315987; Fri, 14 Dec 2012 09:45:26 -0700 (MST) Message-ID: <50CB543A.3020005@ttc-cmc.net> Date: Fri, 14 Dec 2012 09:30:50 -0700 From: dmp User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.13) Gecko/20100914 SeaMonkey/2.0.8 MIME-Version: 1.0 To: Haifeng Liu , pgsql-jdbc@postgresql.org Subject: Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc) References: <50CB4C40.7000104@ttc-cmc.net> In-Reply-To: Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org 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 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