Обсуждение: JDBC and setting statement_timeout

Поиск
Список
Период
Сортировка

JDBC and setting statement_timeout

От
Jason Long
Дата:
In order to keep my application from freezing up when a query pegs my CPU I set statement_timeout=120000, but I read in the manual

"Setting statement_timeout in postgresql.conf is not recommended because it affects all sessions."

I am used JDBC exclusively for the applicatoin and I read here

http://www.nabble.com/Implementing-setQueryTimeout()-ts15537669.html


that setTimeout is not implemented in the JDBC driver for PostgreSQL.

I would like for nearly all of my queries to throw and error if they do not complete in a certain time and if I know if might take more I would like to set this explicitly for that query.

Would someone please comment on the status of setQueryTimeout in the JDBC driver? 
Is there any workaround if this is still not implemented?


Re: JDBC and setting statement_timeout

От
Kris Jurka
Дата:

On Mon, 3 Nov 2008, Jason Long wrote:

> *Would someone please comment on the status of setQueryTimeout in the JDBC
> driver? Is there any workaround if this is still not implemented?*
>

setQueryTimeout is not implemented, the workaround is to manually issue
SET statement_timeout = xxx calls via Statement.execute.

Kris Jurka

Re: JDBC and setting statement_timeout

От
Jason Long
Дата:
Kris Jurka wrote:
>
>
> On Mon, 3 Nov 2008, Jason Long wrote:
>
>> *Would someone please comment on the status of setQueryTimeout in the
>> JDBC driver? Is there any workaround if this is still not implemented?*
>>
>
> setQueryTimeout is not implemented, the workaround is to manually
> issue SET statement_timeout = xxx calls via Statement.execute.
>
> Kris Jurka
1.  Could you provide a code sample to work with straight JDBC?
2.  Can someone advise how this might work with EJB3/Hibernate?