Unfortunately setTimeout is not implemented for JDBC/postgres. Is there some way I can simulate or workaround this? Functionally I want to execute the query and the then break if it takes longer than N seconds
A:
One way might be to try running the query in a Timer class. Throw an exception if the Timer ends without a value returned.
Hibernate and JDO supply such a construct. Maybe they'd be good alternatives for you.
duffymo
2009-07-24 00:11:12
+3
A:
The "statement_timeout" looks like what you want.
SET statement_timeout TO 1000; -- for a second
<your_query_here>;
RESET statement_timeout; -- reset
Milen A. Radev
2009-07-24 00:27:12
You're better off using RESET statement_timeout; after the query has completed - in case there is a default value...
Magnus Hagander
2009-07-24 06:47:52
Fixed now, thanks!
Milen A. Radev
2009-07-24 09:02:12
A:
What if you were to use c3p0 for your dataSource? It has lots of configurable options, and for cranky databases and networks, for example, acquireRetryAttempts, acquireRetryDelay, and breakAfterAcquireFailure.
lumpynose
2009-07-24 00:46:30