Turgon Turgon - 1 month ago 15
SQL Question

Google Apps Script query to MariaDB

We recently moved our data to a new server - however the new one is using MariaDB.

We do a lot of queries and calculations in Google Apps Script for spreadsheet. Since the server switch our scripts return the following error:


Unknown system variable 'OPTION' (line 21, file "")


Line 21 refers to the query inside the following script:

function mysql_invoice() {

// Replace the variables in this block with real values.
var address = 'xxx';
var user = 'xxx';
var userPwd = 'xxx';
var db = 'xxx';

var dbUrl = 'jdbc:mysql://' + address + '/' + db;

// Read up to 100000 rows of data from the table and log them.

var conn = Jdbc.getConnection(dbUrl, user, userPwd);
var stmt = conn.createStatement();


// Call SO DATA
stmt.setMaxRows(10000);
var start = new Date();

var rs = stmt.executeQuery("select * from sales_flat_invoice");


Any ideas?

Answer

I believe the way you used setMaxRows is the problem.

If you change the way you set the limit it will work.

  // Call SO DATA 
  //      stmt.setMaxRows(10000);
  var start = new Date();

  var rs = stmt.executeQuery("select * from sales_flat_invoice limit 10000");

This should fix your problem. This definetly comes from the missmatch of version of your MariaDB and the version of jdbc connector.

Cheers

Comments