我想通过 JDBC 从在 GCloud Kubernetes Engine 中运行的容器连接到我的 Cloud SQL 数据库 (MySQL)。该容器包含一个带有一些 REST 服务的 Java Spring Boot 应用程序。
当我在本地运行 Java 应用程序时,一切正常,应用程序连接到 Cloud SQL DB 也很好。但是,当我将应用程序部署到 GCloud 时,只有在调用服务器 REST API(通过 Postman)时才会收到此响应:
{
"timestamp": "2018-09-27T06:54:22.987+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Could not open JDBC Connection for transaction; nested exception
is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications
link failure\n\nThe last packet sent successfully to the server was 0
milliseconds ago. The driver has not received any packets from the server.",
"path": "/api/user/getDbs"
}
我已经尝试通过在授权选项卡中添加 0.0.0.0/0 来允许所有连接到数据库。我还尝试添加防火墙规则。两者都没有成功。
炎炎设计
相关分类