EvidentSolutions / dalesbred

Dalesbred - a database access library for Java
https://dalesbred.org
MIT License
54 stars 15 forks source link

Specify statement timeout on Database and SqlQuery #46

Closed globalbus closed 4 years ago

globalbus commented 4 years ago

I'm using this library for a very long time. There is one issue that is crucial for me, ability to set timeouts on queries. Right now, there is only one possibility to set timeout, on JDBC Connection parameters (in example, via socketTimeout parameter in Postgresql Driver). By default, there is no timeout on JDBC Statements. That could exhaust all threads on waiting for database state, and set your services unresponsive.

I prepared small pull request with my basic idea of timeouts in Dalesbred. With that, timeout could be set on Database object, globally for all queries or directly on SqlQuery before each execution.