0

I followed the Google Apps Script JDBC example shown at https://developers.google.com/apps-script/jdbc but have been unsuccessful connecting to a MySQL database hosted at Amazon. My connection string looks like this (scrubbed):

var conn = Jdbc.getConnection("jdbc:mysql://myAmazonhost:3306/", "myUser", "myPass");

I'm able to connect remotely to the Amazon MySQL database from my development system using both MySQL Workbench and Navicat and have checked/verified the host name, username and password in the Google script.

I added the Google servers listed under Accessing Local Databases to the Amazon Security Group but no luck. I keep getting the error:

Failed to establish a database connection. Check connection string, username and password.

I'm probably missing something simple. Anyone else connecting from a Google script to an Amazon MySQL database? I'd sure appreciate any advice. Thanks.

(Edit...)

Sorry, I inadvertently removed the database name when I sanitized my example above. The DB name is specified in the code.

var conn = Jdbc.getConnection("jdbc:mysql://myAmazonhost:3306/myDB", "myUser", "myPass"); 

Twelve hours after I posted this question, the script started working--no database connection errors. I built a report that created a spreadsheet using information retrieved from the Amazon MySQL database. (So cool to see all this working in the cloud.)

But... I hadn't made any changes to the JDBC connection string. And no changes were made to the Security Group configuration on the Amazon side. It just started working.

This morning, I started working on the script. I didn't get very far--the big ugly red database connection error message popped up. No changes to code. It just stopped working. I verified the MySQL database is up and accessible from my desktop admin program. No issues.

Is anyone else experiencing erratic connections from Google scripts to external databases? I'm hoping this is just an isolated glitch.

Jerry Spaeder
  • 11
  • 1
  • 4

2 Answers2

1

Turns out that the issue was related to the database engine version. I created a new instance using engine version 5.5.25a and the connection worked. I went back to my original database and modified it from 5.5.8 to 5.5.25a and it worked as well. Not sure what's going on with Google Apps Script but changing the engine version to 5.5.25a fixed the problem.

Jerry Spaeder
  • 11
  • 1
  • 4
0

You have to specify which database to connect to. Try

var conn = Jdbc.getConnection("jdbc:mysql://myAmazonhost:3306/DB_NAME", "myUser", "myPass");
Srik
  • 7,907
  • 2
  • 20
  • 29
  • Sorry, I inadvertently removed the database name when I sanitized my example. The DB name is specified in the code. Are you able to connect to Amazon in your Google script? – Jerry Spaeder Aug 27 '12 at 15:07