Reputation: 3935
Here's the exception that's thrown:
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
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
UPDATE
pom.xml:
-- update2 there's no more need for that file --
Upvotes: 1
Views: 1836
Reputation: 4096
Two things are required for inter-project Cloud SQL communication:
App Engine and Cloud SQL in different projects
For App Engine applications and Cloud SQL instances in different projects, you must grant the default appengine service account (
[PROJECT-ID]@appspot.gserviceaccount.com)
one of the following IAM roles:
- Cloud SQL Client
- Cloud SQL Editor
- Cloud SQL Admin
Upvotes: 0
Reputation: 5126
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.
Upvotes: 1