setQueryTimeout on a JDBC Statement seems to effect the entire connection not just the Statement object

904 views
Skip to first unread message

Kenton Garner

unread,
Jan 2, 2015, 11:52:36 AM1/2/15
to h2-da...@googlegroups.com
I have been having problems with the setQueryTimeout() call effecting more than just the current JDBC Statement object.

I use a couple of different connection pools with H2 and I have noticed that HikariCP changes my query timeout for all of my queries where as BoneCP does not.

I have since determined that HikariCP can be configured to do an initial connection query to test for successful connections. 
A connection Timeout variable ( small value ) is used to quickly timeout if the connection is down. 

HikariCP uses this connection Timeout value by setting the JDBC Statement object query timeout before performing it's initial connection test query. 
This in-turn changes all of my future statement object query timeouts to be this small timeout because H2 has associated this value to the entire connection.

Is there a way for H2 to implement the setQueryTimeout() method to only effect the current Statement object. 
I assume this would require a change to the JDBC Driver code, but I am not sure how difficult this would be.

My alternatives are to ...
1. Disable the HikariCP initial connection test.
2. Reset the query timeout on each and everyone of my JDBC Statement objects before I use them ( yikes ).

Noel Grandin

unread,
Jan 5, 2015, 4:25:55 AM1/5/15
to h2-da...@googlegroups.com


On 2015-01-02 06:52 PM, Kenton Garner wrote:
>
> Is there a way for H2 to implement the setQueryTimeout() method to only effect the current Statement object.

Not easily I'm afraid. I think we'd need to change the protocol to include the timeout on every command.

Perhaps your connection pool has a hook that you can run after it creates the connection?
I know the one I used to use did.
Reply all
Reply to author
Forward
0 new messages