【发布时间】:2016-03-19 20:24:50
【问题描述】:
我运行一个 java 程序并尝试将它与托管数据库一起使用,我自己使用 Mysql 运行 Vserver ubuntu 12.04,具有完全的 root 访问权限。
我更改了my.cnf 以获得更多资源。
当我启动应用程序时,它很快,与本地数据库几乎没有任何区别。
我的问题是,在一段时间不活动后,程序冻结可能是因为连接断开。 任何错误日志中都没有条目。如果我杀死应用程序并重新启动它,它会再次运行,除了 kill 没有其他工作,它是一台 linuxPC。
我使用了?autoReconnect=true,但我不确定这是否正确,这些表是 innodb。
有没有人知道如何避免连接断开或如何确保重新连接?
PS [17.12.2015]
?autoReconnect=true 已被移除
今天终于等到了一些细节
com.openbravo.basic.BasicException:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 2.435.471 milliseconds ago. The last packet sent successfully to the server was 959.832 milliseconds ago.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure
The last packet successfully received from the server was 2.435.471 milliseconds ago. The last packet sent successfully to the server was 959.832 milliseconds ago.
java.net.SocketException:
wait_timeout 太短时会发生这种情况吗?
在“错误”之后,程序再次运行!
【问题讨论】:
-
您能否详细介绍一下您的 java 程序的活动?连接是如何建立的?