Alou Liu
Alou Liu

Reputation: 33

Google Apps Script - JDBC to Google cloud DB connection failed

I have experienced an error when using Google Apps scripts to make connection to Google Cloud Database. The script working just fine before 2021/5/11 11:00AM. After that, the connection cannot be established and return "Failed to establish a database connection. Check connection string, username and password." I have no idea what could be the problem ;-(

The database has no issue using DB Client to connect.

Jdbc.getConnection('jdbc:mysql://' + CFG.IP_ADDR + ':' + CFG.PORT + '/' + CFG.DB_NAME, CFG.ACCOUNT, CFG.PASSWWD);
var CFG = {
IP_ADDR: 'ip address',
PORT: '3306',
DB_NAME: 'DBname',
ACCOUNT: 'account',
PASSWWD: 'pwd',
DRIVER_STRING: 'org.mariadb.jdbc.Driver',
CONNECT_PROPERTIES: 'useSSL=false'
}

Upvotes: 2

Views: 845

Answers (2)

Anthony Rohde
Anthony Rohde

Reputation: 1

I had this issue and it was a Google public IP address being denied access by our firewall. We added the IP address and the problem went away.

Upvotes: 0

Rafa Guillermo
Rafa Guillermo

Reputation: 15357

This appears to be a bug!

There is already a report on Google's Issue Tracker which detail the same kind of behaviour:

Google does seem to know about this issue but if it's causing problems you can also hit the ☆ next to the issue number in the top left on the aforementioned page which lets Google know more people are encountering this and so it is more likely to be seen to faster.

There is a proposed workaround in this issue thread - which is to include the string ?useSSL=false as a URL parameter, (as suggested by spcsLrg in their answer) but it has been reported that this does not work for everyone (and in most cases, if a third-party Database is being used).

Upvotes: 2

Related Questions