Re: Transactions through JDBC

From: "Jan de Visser" <jdevisser(at)digitalfairway(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: "Albert" <alberto(dot)molteni(at)libero(dot)it>
Subject: Re: Transactions through JDBC
Date: 2007-04-11 17:52:18
Message-ID: 200704111352.18516.jdevisser@digitalfairway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday 11 April 2007 12:49:49 Albert wrote:
> Hi all!
>
> Actually I have a client-server application with one server and many
> clients each one of which opens a different connection to the postgres
> database. In order to avoid those known problems with the execution of
> the different clients' operations at database, I implemented
> everything in this way. Each operation is made so:
>
> conn.executeUpdate("BEGIN");
> conn.execute(...)
> conn.execute(...)
> conn.execute(...)
> conn.executeUpdate("COMMIT");
>
> May it be considered right, or am I making something wrong? I use JDBC
> driver for postgres 8.1

You should use

conn.setAutoCommit(false);
conn.execute(...)
conn.execute(...)
conn.execute(...)
conn.commit();

>
> Thanks!

jan

>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
--------------------------------------------------------------
Jan de Visser                     jdevisser(at)digitalfairway(dot)com

                Baruk Khazad! Khazad ai-menu!
--------------------------------------------------------------

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alberto Molteni 2007-04-11 18:01:55 Re: Transactions through JDBC
Previous Message Andrew Edson 2007-04-11 17:50:57 Dumping part (not all) of the data in a database...methods?