BoneCP: Is there a way to set the Statement timeout for all statements?

I'm using a play-java app (play-java 2.2.1, bonecp 0.8.0.RELEASE) that uses BoneCp to access the mysql database and haven't found a way to set timeout for all statements (conf doc here ). All I found was to do it programmatically:

java.sql.Statement.setQueryTimeout(int)

      

I will probably end up all generated statements with an object that will set this value, but I thought I could set it in the config file.

I know that I could use spring or some other framework and set some value for "transaction timeout", but I would like to avoid that.

Thank!

+3


source to share


1 answer


You can fork BoneCP and tweak the StatementHandle to set the default statement timeout to internalStatement

in the constructor (maybe the QueryExecuteTimeLimit parameter is used for it , it's already used in the constructor for this.queryExecuteTimeLimit

).

You can also use JPA / Hibernate with Play , which allows you to set the default Request Timeout . Yes, that means using a framework, but the default timeout is usually not part of the database connection pool.



Please note that the request / statement timeout is NOT the same as the transaction timeout. "Transaction timeout is used to limit the total processing time of an instruction to the maximum allowable amount" and the checkout timeout is a "statement execution timeout limit" (copied from the chapters in this article, "What is a Transaction Timeout?" And "What is a timeout? ").

+1


source







All Articles