From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
To: | Oezcan Acar <acar(at)bizimalem(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: setQueryTimeOut |
Date: | 2004-10-29 23:20:14 |
Message-ID: | Pine.BSO.4.56.0410291812150.16598@leary.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
On Wed, 27 Oct 2004, Oezcan Acar wrote:
> do you now something new about the implementation of
> Statement.setQueryTimeOut ? As far as I now this method is not
> implemented in the current driver. Do you know, how to implement such a
> method? Thank you.
>
There are two ways to approach this problem. With the backend's
statement_timeout config variable and the driver's Statement.cancel()
method. The issue with both of these is that you need to be concerned
about thread safety and only cancelling the correct statement.
Using the backend's statement_timeout is pretty straightforward, before
each query set it and after each query reset it. Issues to be careful of
are making sure the timeout gets reset on errors. I would also be
concerned about the potential overhead of issuing two additional queries
for each user level statement execution.
With the Statement.cancel approach you would create a new thread to wake
up and issue the cancel if the statement hasn't completed yet, but I
believe there are some race conditions that make it difficult to do this
correctly:
http://archives.postgresql.org/pgsql-jdbc/2003-11/msg00148.php
http://archives.postgresql.org/pgsql-jdbc/2003-09/msg00175.php
Kris Jurka
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2004-10-30 15:43:50 | Re: PGobject overhaul (was Re: tightening up on use of oid |
Previous Message | Oliver Jowett | 2004-10-29 21:30:07 | Re: ps.setCharacterStream() and memory usage |