[英]AppEngine gets “Communication link failure” error while trying to connect to Google Cloud MySql instance
I have a Java/Jetty based appengine project that successfully connects to Google cloud MySql server when using TCP connection with JDBC, BUT fails to connect to the same server when trying to make it through Instance name and JDBC socketFactory. I have a Java/Jetty based appengine project that successfully connects to Google cloud MySql server when using TCP connection with JDBC, BUT fails to connect to the same server when trying to make it through Instance name and JDBC socketFactory. the error I am getting in the GCP debug console:我在 GCP 调试控制台中遇到的错误:
"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." “通信链路故障最后一个成功发送到服务器的数据包是 0 毫秒前。>驱动程序没有收到来自服务器的任何数据包。”
try {
Class.forName("com.mysql.jdbc.GoogleDriver");
String url= String.format("jdbc:google:mysql:///"
+ "MY_DB_NAME" + "?"
+ "cloudSqlInstance=%s&"
+ "socketFactory=%s&"
+ "useSSL=false",
"PROJECT-ID:ZONE:INSTANCE_NAME",
"com.google.cloud.sql.mysql.SocketFactory");
return DriverManager.getConnection(url, USER_NAME, USER_PASSWORD);
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
return null;
}
The problem might be in the public IP address that you specify in the cloud mysql instance.问题可能出在您在云 mysql 实例中指定的公共 IP 地址中。 Just check the public IP address by typing What is my public IP?只需通过键入我的公共 IP 是什么来检查公共 IP 地址即可? in the browser.在浏览器中。 Then update the public IP given for the google cloud instance.然后更新为谷歌云实例提供的公共 IP。 This might be help to solve your issue.这可能有助于解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.