Re: setQueryTimeOut(1) - not expected result...
От | Waldomiro |
---|---|
Тема | Re: setQueryTimeOut(1) - not expected result... |
Дата | |
Msg-id | 001601c3e5d2$3b7322c0$1001a8c0@shx.com.br обсуждение исходный текст |
Ответ на | setQueryTimeOut(1) - not expected result... (Guido Fiala <guido.fiala@dka-gmbh.de>) |
Список | 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.fiala@dka-gmbh.de> To: <pgsql-jdbc@postgresql.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
В списке pgsql-jdbc по дате отправления: