pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hadraba Petr <hadrabap@bluetone.cz>
To: pgsql-jdbc@postgresql.org
Subject: Batch Update problem
Date: Sun, 30 Dec 2007 03:22:45 +0100
Message-ID: <371765080712291822wc20b67fvaa0a495c1051088c@mail.gmail.com> (raw)

Hello all!

I'm running into strange issues with JDBC Driver v 8.2 build 507. I'm
using the JDBC 3 driver.

My code looks like:

I have a global PreparedStatement pStmt that handles the UPDATE statement.

In for-cycle I'm doing the following:
 - prepare values for the UPDATE
 - call pStmt.clearParameters();
 - call pStmt.setObject(paramOrderID, paramValue) for each value with
the right paramID and value
 - call pStmt.addbatch();

After the for-cycle I'm calling the pStmt.executeBatch(); and pStmt.close();

Please note, no Exceptions are thrown — the SQL code is correct and no
primary key nor foreign key valoations are occuring.

With the downloaded version, no UPDATES are processed. In the same
transaction (before commit) all UPDATES are written, but after the
dbConnection.commin(); all changes are lost.
With my-own-compiled version (JDBC 3g, against Java SE 5) is all
working properly.

My JDBC initialization code looks like:
 dbConnection.rollback();
 dbConnection.setAutoCommit(false);

I don't want to use the AutoCommit "feature".

What I'm doing wrong?

I'm able to post full source code and more info.

Please note, that all is working properly with my own JDBC v 3g
version. It's strange.


Thank you for your help.


Sincerely

PETR

P.S.: I investigated the source code and I didn't find any difference
in PreparedStatement in versions v 3 vs. v 3g, unfortunetly. All the
implementations are extending the PreparedStatement from JDBC v 2 :-(

Thank you!


Message-ID: <371765080712291822wc20b67fvaa0a495c1051088c@mail.gmail.com>
Permalink:  ../371765080712291822wc20b67fvaa0a495c1051088c@mail.gmail.com/
Also on:    postgresql.org/message-id/371765080712291822wc20b67fvaa0a495c1051088c@mail.gmail.com

 · 

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: hadrabap@bluetone.cz
  Subject: Re: Batch Update problem
  In-Reply-To: <371765080712291822wc20b67fvaa0a495c1051088c@mail.gmail.com>
  References: <371765080712291822wc20b67fvaa0a495c1051088c@mail.gmail.com>

* 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