Google Apps Script JDBC ResultSet for Array

Is there a better way to get results from a ResultSet? Calling getString()

for each value is very slow. It takes up to 2.5 seconds to put about 400 rows, 16 columns into an array before I can use it.

The query itself takes about 80ms, which is faster than accessing a google sheet (about 2 seconds), but it takes too long to read the data.

This is what I am currently using.

  var results = stmt.executeQuery();
  var numCols = results.getMetaData().getColumnCount();
  var resultsArray = [];
  var count = 0;
  while(results.next()) {
      resultsArray.push([]);
      for (var i = 1; i <= numCols; i++)
          resultsArray[count].push(results.getString(i));
      count++;
  }

      

+3


source to share





All Articles