Re: Select For Update question

From: Barry Lind <blind(at)xythos(dot)com>
To: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
Cc: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Select For Update question
Date: 2003-03-26 06:40:40
Message-ID: 3E814B68.3040904@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Jean-Christian,

You are using the correct syntax. The only thing I can think of is that
the locks are being released because you are ending the transaction by a
commit or rollback. You are running with AutoCommit turned off aren't
you? Without autocommit being turned off, the locks will be immediately
released as soon as the statement autocommits and ends the tranaction.

thanks,
--Barry

Jean-Christian Imbeault wrote:
> I would like to use a SELECT ... FOR UPDATE statement in my Java program
> in order to lock some rows while I do some work on them. However either
> I don't understand how to use the JDBC connection properly of the FOR
> UPDATE construct doesn't work with the JDBC driver.
>
> As a test case I built a small GUI with just one button. When I click
> the button the following sql is executed:
>
> "select * from test for update";
>
> While the GUI is still open I open a psql console and I am capable of
> manually updating the rows in the test table ... they are not locked as
> I had hoped.
>
> What is the proper way to use select .. for update with the JDC driver?
> Can someone point me to some example or documentation?
>
> Thanks,
>
> Jean-Christian Imbeault
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jean-Christian Imbeault 2003-03-26 06:44:47 Re: Select For Update question
Previous Message Barry Lind 2003-03-26 06:35:50 Re: jdbc.postgresql.org