Setting a query timeout

50 views
Skip to first unread message

Thierry D.

unread,
Jun 17, 2015, 9:20:28 AM6/17/15
to activejd...@googlegroups.com
Hi all,

Does anyone know if there is a way to set a query timeout in ActiveJDCB?

Thanks.

Igor Polevoy

unread,
Jun 17, 2015, 12:38:01 PM6/17/15
to activejd...@googlegroups.com
You would do that based on your JDBC driver specification. ActiveJDBC has nothing to do with that. 

In MySQL, you can configure many parameters in the URL like this:

jdbc:mysql://localhost/testenv?rewriteBatchedStatements=true&characterEncoding=UTF-8&characterSetResults=UTF-8

Check with your JDBC driver docs. 

Thierry DÉHAIS

unread,
Jun 19, 2015, 5:42:40 AM6/19/15
to activejd...@googlegroups.com
Okay, many thanks for the tip.
I think setting the timeout at the driver level is enough for my use case.

But I'm not entirely convinced that it is out of ActiveJDBC's scope.
ActiveJDBC use the Statement objects, and as such,statements timeouts may be used (setQueryTimeout()). Unlike with the driver level setting which closes the connection, setting the timeout at the statement level throws an SQLTimeoutException, leaving the connection open and useable (almost useable, since i've encountered some driver bugs with Oracle).

Anyway, thank you for the solution provided.

--
You received this message because you are subscribed to a topic in the Google Groups "ActiveJDBC Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/activejdbc-group/-iYRsFRnBg0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to activejdbc-gro...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Igor Polevoy

unread,
Jun 20, 2015, 2:26:35 PM6/20/15
to activejd...@googlegroups.com, thierry...@laposte.net
I see your point!
But... f you can do this at the URL or driver configuration level, that would be best. 
Adding this feature on the level of Base/DB classes is easy, but adding at a Model level will be tricky. 

In any case if you have timing issues with DB connection, maybe you have other systemic problems, such as slow hardware, bad network, etc? 

Thanks

Thierry D.

unread,
Jun 23, 2015, 3:32:23 AM6/23/15
to activejd...@googlegroups.com
I understand the complexity for such a feature. I was just checking I hadn't oversee a possible solution. And, as you pointed, I had.
For information, timing issues don't come from hardware or network lantencies, but from databases locks.
Reply all
Reply to author
Forward
0 new messages