Re: jdbc batch insert

From: Kris Jurka <books(at)ejurka(dot)com>
To: Sriram Dandapani <sdandapani(at)counterpane(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: jdbc batch insert
Date: 2006-09-29 16:47:41
Message-ID: Pine.BSO.4.63.0609291146010.8237@leary2.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jim Nasby 2006-09-29 17:21:52 Re: [JDBC] number of transactions doubling
Previous Message Guy Rouillier 2006-09-29 16:44:00 Re: Problem with driver JDBC