Search code examples
google-app-enginegoogle-cloud-sql

App Engine and Cloud Sql Second Generation


I am trying to connect to Cloud Sql 2nd generation by using jdbc connector, by typing:

url = jdbc:google:mysql://project:region:instance/database?user=root

However, when doing this:

DriverManager.getConnection(url);

All I get is a null value.

I did not experience any trouble with first generation and old connection string, but I am not able to get this one working.

Anything in particular that I should consider like settings, missing code/connector? Any help will be greatly appreciated.

Thanks in advance!


Solution

  • Thanks to Vadim suggestion, I could find that there was a problem sending the wrong credentials to the database.

    I will post the jdbc connection string here, since I could not find the complete way for the connection string in any page, I just found separate portions to build it.

    Here it goes:

    url = "jdbc:google:mysql://<your-project-id>:<your-cloud-sql-region>:<your-cloud-sql-instance>/<your-database-name>?user=<your-user>&password=<your-password>";
    

    Hope this can help to save some time!