I would like to fill in a google spreadsheet cell with the output of a mysql database query, so I've written this simple script following the example in the google tutorial:
function get_tbs_number() {
var conn = Jdbc.getConnection("jdbc:mysql://127.0.0.1:9008/icadata");
var stmt = conn.createStatement();
stmt.setMaxRows(100);
var start = new Date();
var rs = stmt.executeQuery("select count(*) from CNGSfiltered where run=10269 and (GTO1>4 or GTO2>4 or GTO3>4 or GTO4>4);");
var doc = SpreadsheetApp.getActiveSpreadsheet();
var cell = doc.getRange('a1');
cell.offset(0, 0).setValue(rs.getString(1));
rs.close();
stmt.close();
conn.close();
var end = new Date();
Logger.log("time took: " + (end.getTime() - start.getTime()));
}
The problem is that when I try to run the script a get an error connecting to the database, while the connection to the same database from command line (mysql -h localhost -P 9008 -u # -p# icadata) does work.