开发者

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:

  1. In your JDBCTempalte xml - <property name="queryTimeout" value="${query.timeout} />
  2. Use a PropertyPlaceholderConfigurer to load properties from a .properties file on the classpath. The easiest way is through <context:property-placeholder location=".." />
  3. Add the query.timeout=x in your .properties files
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜