pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Csaba Nagy <nagy@ecircle-ag.com>
To: Mican Bican <mican58@gmail.com>
Cc: Postgres general mailing list <pgsql-general@postgresql.org>
Subject: Re: [JDBC] java is locked when select for update
Date: Wed, 09 Mar 2005 17:44:32 +0100
Message-ID: <1110386672.2838.65.camel@coppola.muc.ecircle.de> (raw)
In-Reply-To: <915cd38805030908299beca3c@mail.gmail.com>
References: <915cd3880503081437272e5cfb@mail.gmail.com>
	<915cd38805030907545882333f@mail.gmail.com>
	<1110384760.2838.56.camel@coppola.muc.ecircle.de>
	<915cd38805030908299beca3c@mail.gmail.com>

Please post to the list too when replying...

On Wed, 2005-03-09 at 17:29, Mican Bican wrote:
> Thank you for your answer. The reason of so long transactions is that
> I first Insert a row than get the last ID (primary key) and select it
> for update from the database and wait for user to commit it..
> I need the key becouse I will insert rows with references to this new
> row (like adresses to user etc.) ..so the user cann add some adresses
> to a user and when he press ok I commit the statement...
> 
I can't see why you couldn't insert the user in a first transaction and
the addresses in further transactions... if the user gets deleted in the
meantime by somebody else, then inserting the address will fail and you
will tell the user about the error. And if you don't want other people
to see the new user before it is committed with all it's addresses, then
collect first the user data + all the address data, and then open a
transaction and insert the user and the addresses when the user presses
OK. The point is that there should not be any GUI activity between the
start and end of a transaction.
If you really need a lock (I doubt it) between updates, implement it
using some application logic, don't use the DB row locking for long
living locks. I think there is some locking helper in the contrib
modules of postgres, or if not, read up on resource locking on google.

Cheers,
Csaba.





view thread (6+ messages)  latest in thread

Message-ID: <1110386672.2838.65.camel@coppola.muc.ecircle.de>
Permalink:  ../1110386672.2838.65.camel@coppola.muc.ecircle.de/
Also on:    postgresql.org/message-id/1110386672.2838.65.camel@coppola.muc.ecircle.de

 · 

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: nagy@ecircle-ag.com, mican58@gmail.com, pgsql-general@postgresql.org
  Subject: Re: [JDBC] java is locked when select for update
  In-Reply-To: <1110386672.2838.65.camel@coppola.muc.ecircle.de>
  References: <915cd3880503081437272e5cfb@mail.gmail.com> <915cd38805030907545882333f@mail.gmail.com> <1110384760.2838.56.camel@coppola.muc.ecircle.de> <915cd38805030908299beca3c@mail.gmail.com> <1110386672.2838.65.camel@coppola.muc.ecircle.de>

* 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