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$1001a8c0@shx.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Guido,

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
record.

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
record.

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
record.

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).

wmiro.

----- 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...

Hallo,

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

//user1:

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

//user2:

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

I would think, that the second user get's a query timeout on his query, but
it
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?

Guido

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

In response to

Browse pgsql-jdbc by date

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