【发布时间】:2017-09-23 06:07:59
【问题描述】:
请给我一个机会解释我的神秘情况。
我的 Glassfish 服务器无法连接到远程 MySQL 数据库。
我检查了以下说明
- ping 到远程主机 - 正常
- 通过mysql命令连接(mysql -h remote -u user -p) - OK
- ssh 端口转发 (ssh -L13306:localhost:3306 remote) 并配置 glassfish 使用它 (jdbc://127.0.0.0:13306/mydb) - OK
我认为我的配置(服务器名称、数据库名称、用户名和密码)是正确的。 但还是无法连接数据库。
我的环境:
本地端
- Ubuntu 17.04
- Oracle Java 1.8.0 u131
- Glassfish 4.1(内部版本 13)
- MySQL 连接器/J 5.1.41
远端
- FreeBSD 11
- MySQL 5.5.46
我昨晚用谷歌搜索了,但找不到答案。
4 月 28 日编辑:
我的 server.log 说:
[2017-04-26T09:03:07.932+0900] [glassfish 4.1] [WARNING] [test.connection.pool.failed] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.connectors.service] [tid: _ThreadID=98 _ThreadName=admin-listen
er(6)] [timeMillis: 1493164987932] [levelValue: 900] [[
RAR8054: Exception while creating an unpooled [test] connection for pool [ MysqlMacms ], Connection could not be allocated because: 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.]]
[2017-04-26T09:03:07.940+0900] [glassfish 4.1] [SEVERE] [] [org.glassfish.admingui] [tid: _ThreadID=49 _ThreadName=admin-listener(5)] [timeMillis: 1493164987940] [levelValue: 1000] [[
RestResponse.getResponse() gives FAILURE. endpoint = 'http://localhost:4848/management/domain/resources/ping-connection-pool.json'; attrs = '{id=admtkMysqlMacms}']]
【问题讨论】:
-
我已经用 Payara Server 4.1.1.171.1 #badassfish (build 139) 进行了测试,但问题没有解决。
-
我想知道一些 Java 策略和/或 apparmor 会阻止传出数据包。
-
这个stackoverflow.com/questions/13281683/… 似乎是同样的问题。
-
能否请您发布带有完整堆栈跟踪的错误?
标签: java mysql ubuntu glassfish