无法从App Engine flex Java上的其他项目连接到Cloud SQL [英] Unable to connect to Cloud SQL from different project on App Engine flex Java

查看:69
本文介绍了无法从App Engine flex Java上的其他项目连接到Cloud SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是引发的异常:

javax.servlet.ServletException: javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.

稍后我也会在堆栈跟踪中获得此消息:

I also get this message later on the stack trace:

Caused by: java.lang.RuntimeException: The Google Cloud SQL API is not enabled for project [xxxxxx]. Please use the Google Developers Console to enable it: https://console.cloud.google.com/apis/api/sqladmin/overview?project=xxxxxx

当我单击控制台链接时,我可以看到Cloud SQL Api已启用,并且当数据库位于同一项目中时,代码可以正常工作.我还添加了AppEngine flexible服务帐户,该帐户在包含Cloud SQL数据库且角色为Cloud SQL Client的项目中具有App Engine flexible environment Service Agent角色.

When I click on the console link, I can see that the Cloud SQL Api is enabled and the code was working perfectly when the database was on the same project. I also added the AppEngine flexible service account that has the App Engine flexible environment Service Agent role in the project containing the Cloud SQL database with the role Cloud SQL Client.

接下来我应该尝试什么?谢谢

What should I try next ? Thanks

更新

pom.xml:

-update2不再需要该文件-

-- update2 there's no more need for that file --

推荐答案

在其他项目中访问Cloud SQL实例时,在源项目中启用Cloud SQL Admin API非常重要.复制错误消息中的链接,然后用其他项目ID替换项目ID.当前消息会误导您,因为它当前假设实例位于同一项目中.

When accessing a Cloud SQL instance in a different project, it's important that the Cloud SQL Admin API is enabled in the source project. Copy the link in the error message and replace the project id with the other project id. The current message is misleading as it currently assumes the instance is in the same project.

这篇关于无法从App Engine flex Java上的其他项目连接到Cloud SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆