docker java应用程序无法连接主机mySQL

时间:2020-06-25 02:41:22

标签: java mysql docker networking

运行Windows 10 docker桌面版本 代码可以很好地连接到RDS实例。但是在连接到托管数据库(必须在VPN上)时给出了以下错误消息

docker run raasapp:test
Exception in thread "main" com.mysql.cj.jdbc.exceptions.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 com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
        at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
        at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
        at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
        at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at com.test.RDSConnectionTest.getConnection(RDSConnectionTest.java:18)
        at com.test.RDSConnectionTest.main(RDSConnectionTest.java:50)
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure

0 个答案:

没有答案