pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Sriram Dandapani <sdandapani@counterpane.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: jdbc batch insert
Date: Fri, 29 Sep 2006 11:47:41 -0500 (EST)
Message-ID: <Pine.BSO.4.63.0609291146010.8237@leary2.csoft.net> (raw)
In-Reply-To: <6992E470F12A444BB787B5C937B9D4DF060E5BB1@ca-mail1.cis.local>
References: <6992E470F12A444BB787B5C937B9D4DF060E5BB1@ca-mail1.cis.local>



On Fri, 29 Sep 2006, Sriram Dandapani wrote:

> I have a problem where the batch inserts behave as if the transactions
> were done on a single row by single row basis. When I check the return
> value of the batch update

Transactions and affected row counts have nothing to do with each other.

> int[]  updateStatus = preparedStatement.executeBatch();
>
> I get as many array entries as the number of rows inserted.
>

That's what the JDBC spec says you should get.  Consider if your batches 
were instead "UPDATE TAB SET x= ? WHERE y = ?".  Depending on your y value 
you would get a different number of updated rows, so you need one affected 
row count per batch entry.

Kris Jurka



view thread (2+ messages)

Message-ID: <Pine.BSO.4.63.0609291146010.8237@leary2.csoft.net>
Permalink:  ../Pine.BSO.4.63.0609291146010.8237@leary2.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.63.0609291146010.8237@leary2.csoft.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: books@ejurka.com, sdandapani@counterpane.com
  Subject: Re: jdbc batch insert
  In-Reply-To: <Pine.BSO.4.63.0609291146010.8237@leary2.csoft.net>
  References: <6992E470F12A444BB787B5C937B9D4DF060E5BB1@ca-mail1.cis.local> <Pine.BSO.4.63.0609291146010.8237@leary2.csoft.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