Skip site navigation (1) Skip section navigation (2)

Re: setQueryTimeOut(1) - not expected result...

From: "Waldomiro" <wmiro(at)ig(dot)com(dot)br>
To: "Guido Fiala" <guido(dot)fiala(at)dka-gmbh(dot)de>,<pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: setQueryTimeOut(1) - not expected result...
Date: 2004-01-28 19:09:17
Message-ID: 001601c3e5d2$3b7322c0$ (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

I had the same situation, I didn't use Transactions because I'd lock the
record when the first user start to edit and not when the user save the

I did like this:

I create 2 tables on my postgres database :

the first table I use to register the user login, this file has a serial
field which give me a different sequence each login.

the second table I use to register that login sequence started to edit a

always before start to edit a record I check the second file and if the
record is there I show a message saying there is another user editing the

this solution has a few problems, like "turn off the computer without delete
the records from a second file", so I create a thread in Java which every 1
minute update the first file ("login file")

so, when I check the second table I check the first either and if the login
time was more than 2 minutes It mean the record isn't locked anymore because
the login that was locking this record didn't update his login (the user
turn off the computer).


----- Original Message -----
From: "Guido Fiala" <guido(dot)fiala(at)dka-gmbh(dot)de>
To: <pgsql-jdbc(at)postgresql(dot)org>
Sent: Wednesday, January 28, 2004 11:52 AM
Subject: [JDBC] setQueryTimeOut(1) - not expected result...


assuming one has 2 users which try to lock the same record for edit at a
the one coming later should be informed of the situation, i like to do the


stmt.setQueryTimeout(1);//wait just one second
ResultSet rs=stmt.executeQuery("BEGIN;SELECT * FROM mytable FOR UPDATE OF


ResultSet rs=stmt.executeQuery("BEGIN;SELECT * FROM mytable FOR UPDATE OF
(if timeoutinform user...)

I would think, that the second user get's a query timeout on his query, but
does not seem to work. Instead the think seems to wait forever.

Immediately after user1 does and "COMMIT;" the user2 get's his ResultSet.

What am i doing wrong?


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

In response to

pgsql-jdbc by date

Next:From: Dave PageDate: 2004-01-28 20:15:16
Subject: FW: [webmaster] jdbc site: documentation links broken
Previous:From: michel.verplanckeDate: 2004-01-28 17:40:57
Subject: Connection problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group