I'm trying to connect AWS RDS to Google Sheets, but all i get is
Failed to establish a database connection. Check connection string, username and password.
I have tried the method found in trackers i.e, "using the IP of the endpoint host address", but still the same error occurs,
I have:
Set [RDS SETTINGS - public accessibilty- ON] & verified that endpoint and access details work on all other viewers (Navicat, Adminer etc.)
added all the google IP's needed to white-list(refer: https://developers.google.com/apps-script/guides/jdbc ) in 'RDS VPC- Security Groups' inbound & outbound.
Here's the code i'm using:
var connectionName = 'x.x.x.x:3306'
var user = 'admin';
var userPwd = 'pass';
var db = 'dbname';
var dbUrl = 'jdbc:mysql://' + connectionName + '/' + db;
function readFromTable11() {
var conn = Jdbc.getConnection(dbUrl, user, userPwd); //error here
Logger.log(conn);
var start = new Date();
var stmt = conn.createStatement();
stmt.setMaxRows(1000);
var results = stmt.executeQuery('SELECT * FROM items');
var numCols = results.getMetaData().getColumnCount();
while (results.next()) {
var rowString = '';
for (var col = 0; col < numCols; col++) {
rowString += results.getString(col + 1) + '\t';
}
Logger.log(rowString);
}
results.close();
stmt.close();
var end = new Date();
Logger.log('Time elapsed: %sms', end - start);
}
I've scoured the net & still couldn't get it to work.
Okay, turns out that Google Scripts only supports MySql v5.5.x versions, so going above that causes the issue to be a "failed database connection." so to make sure successful connection, just make the same settings above in RDS but select MySQL Engine to have version 5.5.x & use this - (toolbox.googleapps.com/apps/dig) to lookup your endpoints IP address for possible DNS problems. I'll update more.