I am using a play application (play-java 2.2.1, bonecp 0.8.0.RELEASE) that uses BoneCp to access a mysql database, and did not found a way to set the statement timeout for all statements (conf doc here). All I found is how to do ir programmatically:
java.sql.Statement.setQueryTimeout(int)
I will probably end up wrapping all created statements with an object that will set that value, but I thought I could set it in the configuration file.
I know I could use spring or some other framework and set some kind of "transaction timeout" value, but I'd like to avoid that.
Thanks!
You could fork BoneCP and adjust the StatementHandle class to set a default statement timeout on internalStatement
in the constructor (maybe abuse the QueryExecuteTimeLimit configuration option for it, it is already used in the constructor for this.queryExecuteTimeLimit
).
You can also use JPA/Hibernate with Play which allows you to set a default query timeout. Yes, that means using a framework but a default statement timeout is typically not part of a database connection pool.
Note that a query/statement timeout is NOT the same as a transaction timeout. A "transaction timeout is used to limit the total statement processing time to the maximum amount allowed" and a statement timeout is a "limitation on how long a statement should run" (copied from this article chapters "What is Transaction Timeout?" and "What is Statement Timeout?").