Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TjXrK-000440-LN for pgsql-jdbc@arkaria.postgresql.org; Fri, 14 Dec 2012 16:11:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TjXrJ-0008H8-Gd for pgsql-jdbc@arkaria.postgresql.org; Fri, 14 Dec 2012 16:11:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TjXrJ-0008H3-0m for pgsql-jdbc@postgresql.org; Fri, 14 Dec 2012 16:11:33 +0000 Received: from outbound.vnet-inc.com ([216.146.104.103]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TjXrC-00005a-8L for pgsql-jdbc@postgresql.org; Fri, 14 Dec 2012 16:11:32 +0000 Received: from [192.168.157.132] (unknown [76.75.27.41]) by outbound.vnet-inc.com (Postfix) with ESMTP id 4050459CB; Fri, 14 Dec 2012 09:11:24 -0700 (MST) Message-ID: <50CB4C40.7000104@ttc-cmc.net> Date: Fri, 14 Dec 2012 08:56:48 -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: 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, 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. Statement.executeBatch(). executeBatch int[] executeBatch() throws SQLException ~ ~ ~ If one of the commands in a batch update fails to execute properly, this method throws a BatchUpdateException, and a JDBC driver may or may not continue to process the remaining commands in the batch. However, the driver's behavior must be consistent with a particular DBMS, either always continuing to process commands or never continuing to process commands. If the driver continues processing after a failure, the array returned by the method BatchUpdateException.getUpdateCounts will contain as many elements as there are commands in the batch, and at least one of the elements will be the following: ~ ~ ~ Returns: an array of update counts containing one element for each command in the batch. The elements of the array are ordered according to the order in which commands were added to the batch. Throws: SQLException - if a database access error occurs, this method is called on a closed Statement or the driver does not support batch statements. Throws BatchUpdateException (a subclass of SQLException) if one of the commands sent to the database fails to execute properly or attempts to return a result set. You may be able to answer your own question by examining the int[] array that is returned by way of BatchUpdateException.getUpdateCounts() danap. Haifeng Liu wrote: >> Hi, >> >> I have a DB writer program written in Java, it do batch updates, and >> will try to update each record in a batch if it failed. I think no any >> record in a batch will be update if the batch failed, but weirdly I >> found a few records update twice(very little amount among all records). >> >> Well, there is less stuff about postgresql jdbc driver. I wanna know >> if executeBatch really keep all the records in a batch untouched when >> the batch failed. Any help is appreciate. -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc