Tomcat 6 MySQL->;奇怪的连接错误

Tomcat 6 MySQL->;奇怪的连接错误,mysql,tomcat,Mysql,Tomcat,我有一个带有Apache->mod_jk->Tomcat 6->MySQL的Ubuntu服务器。每次Tomcat加载新的*.war或重新启动时,都会出现以下错误: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver

我有一个带有Apache->mod_jk->Tomcat 6->MySQL的Ubuntu服务器。每次Tomcat加载新的*.war或重新启动时,都会出现以下错误:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
现在奇怪的是:有时在一段时间后(有时是几分钟或几小时),什么也不做,应用程序就像一个符咒一样工作——没有任何其他错误

这个连接是用tomcat本身(使用这个上下文容器)建立的,并且是127.0.0.1 phpmyadmin也没有问题。

Remy, 不幸的是,这个问题没有一个“简单”的答案,因为它在许多方面都有所不同。您收到的错误是一个一般通信错误,tomcat将其交回表示通信问题,而不会详细说明问题是什么

首先,我建议检查您的mysql是否正在监听127.0.0.1,而不仅仅是本地主机。区别的原因是,具有ipv6的服务器(即使它只是一个本地::1)将首先尝试使用此连接

如果您执行netstat-an | grep侦听,您应该会看到端口3306。那个插座在听什么?确保这与您在tomcat设置中指定的内容相匹配,然后继续