setQueryTimeOut(1) - not expected result... - Mailing list pgsql-jdbc

From Guido Fiala
Subject setQueryTimeOut(1) - not expected result...
Date
Msg-id 200401281452.23064.guido.fiala@dka-gmbh.de
Whole thread Raw
Responses Re: setQueryTimeOut(1) - not expected result...
List pgsql-jdbc
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

pgsql-jdbc by date:

Previous
From: Guido Fiala
Date:
Subject: Re: getting primary key values for inserted records?
Next
From: "scott.marlowe"
Date:
Subject: Re: getting primary key values for inserted records?