当应用程序尝试与 DB 建立连接时,我遇到了通信链接故障。
[#|2010-04-08T20:09:57.825+0300|SEVERE|glassfish3.0|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=24;_ThreadName=Thread-1;|Cannot connect to database server = 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.|#]
正是在这个字符串:
Statement s = conn.createStatement();
其中conn定义如下:
private static java.sql.Connection conn;
对于这个应用程序,我设置了一个带有默认参数的连接池,目前它(应用程序)同时使用 JPA 和直接 JDBC 查询。连接池的重新创建什么也没做,连接池 ping 给出了下一条消息:
Ping Connection Pool for pool is Failed. Ping failed Exce
ption - Connection could not be allocated because: Communications lin
k failure%%%EOL%%%%%%EOL%%%The last packet sent successfully to the s
erver was 0 milliseconds ago. The driver has not received any packets
from the server. Please check the server.log for more details.%%%EOL
%%%Ping failed Exception - Connection could not be allocated because:
Communications link failure
并刷新连接池给出:
com.sun.enterprise.admin.cli.CommandException: remote failure: Failed to flush connection pool ...
但是我可以从终端连接到数据库。此外,我有相同的应用程序在我的本地机器上运行,具有相同的连接池设置。
任何人都知道发生了什么或如何解决问题?