1
votes

I'm trying to connect from my Google Apps Script project to my Google Cloud SQL (second generation) instance. Here's the code I've got now.

I was able to connect to it successfully when connecting thru IP, but that's unencrypted. All of the Google Apps Script IPs are whitelisted also.

If my Instance ID is 12345 then my Instance connection name is 12345:us-west1:12345.

  var conn = Jdbc.getCloudSqlConnection('jdbc:google:rdbms://instanceConnectionName/database',{user: 'username', password: 'password'});

I've tried:

  • Taking the username and password out of the curly braces, so it's just string, string, string
  • Using the instance name (keep in mind the difference between Instance ID and Instance connection name)
  • Removing the database
  • Removing the //
  • Switching authentication modes (AuthMode.LIMITED and AuthMode.NONE)
  • A whole bunch of other stuff

So basically, I just can't figure it out and some help would be appreciated it. Thank you!

1

1 Answers

2
votes

Google's documentation is difficult to understand here. Basically, they tell you that the connection url must look like this:

var conn = Jdbc.getCloudSqlConnection('jdbc:google:rdbms:subname');

However, for a MySQL database, it must look like this:

var conn = Jdbc.getCloudSqlConnection('jdbc:google:mysql://subname');

Just replace rdbms with mysql. That's it.