SingleConnectionDataSource连接在大约40分钟后不活动关闭 [英] SingleConnectionDataSource connection closed after about 40 minutes inactivity
问题描述
我们在 org.springframework.jdbc.datasource.SingleConnectionDataSource
?
我们配置了数据源
< property name =suppressClosevalue =true/>
应该如何解决问题。
We configured datasource with
<property name="suppressClose" value="true"/>
what should solve the problem.
连接在大约30-40分钟不活动(当数据库和应用程序之间没有流量时)时关闭。
And the problem is that the connection is closed after about 30-40 minutes of inactivity (when there is no traffic between db and application).
也许有人使用SingleConnectionDataSource的人可以帮助解决这个问题错误或功能。
Maybe someone with experience with SingleConnectionDataSource can help how to solve this bug or feature.
推荐答案
如果在SimpleConnectionDataSource下,使用MySql连接,那么通常会在30-40分钟后删除的不活动。即使您使用直接JDBC并通过以下方式创建连接:
If underneath SimpleConnectionDataSource, a MySql connection is used, then it will usually be dropped after 30-40 minutes of inactivity. Even if you use straight JDBC and create connection via:
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager
.getConnection("jdbc:mysql://localhost/mydatabase?user=username&password=pass");
它也会在30-40分钟后丢弃。
It will also be dropped after 30-40 mins.
这篇关于SingleConnectionDataSource连接在大约40分钟后不活动关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!