I have deployed on appengine a basic java web app that is supposed to connect to a postgresql instance on Cloud SQL (works locally). After deployment It (wrongly?) raise this exception when I browse the page that tries to connect to the DB:
org.postgresql.Driver connect: Unexpected connection error: (Driver.java:271) java.lang.RuntimeException: The Google Cloud SQL API is not enabled for project [ad*****manager-XXXXXXX]. Please use the Google Developers Console to enable it: https://console.cloud.google.com/apis/api/sqladmin/overview?project=ad*****manager-XXXXXXX
- I have checked that the Google Cloud SQL API is enabled as you can see on that screenshot
- I have granted the cloud sql editor rights to my app on the project that hosts the instance (Note that the postgresql instance and the web app live in two separate projects.)
- It is a flex environment app
Here is the part of the code that fails:
Class.forName("org.postgresql.Driver");
connection = DriverManager.getConnection(dburl, dbuser, dbpwd);
And the connection url:
jdbc:postgresql://google/name_of_my_database?useSSL=false&socketFactoryArg=ad*****manager-XXXXXXX:europe-west1:XXXX-pgdb-preprod&socketFactory=com.google.cloud.sql.postgres.SocketFactory