Setting up connection time out using configuration
I realized that I haven't set the time out for the JDBCTemplate
using the setQueryTimeOut
method. My code is in production as I would ideally want a solution to set the timeout from some configuration instead of recompiling the code. Is there a way to set the query time out via say the data source configuration or any other property outside the Java.
I tried via the accepted solution to this post. Didn't work for me开发者_Go百科. I get org.springframework.beans.NotWritablePropertyException: Invalid property 'connectionProperties' of bean class
You can use the queryTimeout
field with configuration:
- In your JDBCTempalte xml -
<property name="queryTimeout" value="${query.timeout}
/> - Use a
PropertyPlaceholderConfigurer
to load properties from a.properties
file on the classpath. The easiest way is through<context:property-placeholder location=".." />
- Add the
query.timeout=x
in your.properties
files
精彩评论