由于超时或客户要求而取消的对帐单 [英] Statement cancelled due to timeout or client request

查看:101
本文介绍了由于超时或客户要求而取消的对帐单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google App脚本将数据添加到我的Google Cloud SQL数据库中.我的代码昨晚结束时工作正常,但是今天早晨运行时,它现在给我错误由于超时或客户端请求而取消了声明",我在云控制台中遇到的错误是得到了一个错误阅读信息"通信数据包".

I am trying to add data to my Google Cloud SQL database using Google App Script. My code was working fine last night when I finished but when I ran it this morning it is now giving me the error "statement cancelled due to timeout or client request", the error I am getting in the cloud console is "Got an error reading communication packets".

昨晚它正在处理大约1600行数据.我玩弄了它,并缩小了范围,以至于当15行多了时,就会发生错误. 15行会很好地添加数据,将其更改为16行会引发错误,这告诉我这不是连接本身.我还通过将第15行复制到第16行并删除了所有其他数据来测试了电子表格中的数据,但这没有用.我对我读过的所有内容都表示正在超时感到困惑,主要是因为昨晚它可以正常处理1600行数据.我的代码如下:

Last night it was processing about 1,600 lines of data. I have played around with it and narrowed it down that the error will occur when there is more the 15 lines. 15 lines it will add the data fine, change it to 16 lines and it throws the error, this tells me that it is not the connection itself. I have also tested the data in the spreadsheet by copying line 15 into line 16 and deleting all other data, this did not work. My main confusion with everything I have read saying it is timing out, is that it was working fine last night with 1,600 rows of data. My code is below:

function connection(folderId, db, c1, c2, c3, c4, c5, c6, c7) {
  var files = DriveApp.getFolderById(folderId).getFiles();
  var excelfile = files.next();
  var fileId = excelfile.getId();
  var data = SpreadsheetApp.openById(fileId).getSheetByName('Report 1');
  var last = data.getLastRow()
  var sheetdata=data.getRange("B5:H16").getValues();

  var conn = Jdbc.getCloudSqlConnection(dbUrl, user, userPwd);//dburl is not defined

  conn.setAutoCommit(false); 
  var start = new Date();
  var stmt = conn.prepareStatement('INSERT INTO '+ db + ' ' + '('+c1+','+c2+','+c3+','+c4+','+c5+','+c6+','+c7+') values (?, ?, ?, ?, ?, ?, ?)');
  for (var i=0; i<sheetdata.length; i++) {
    stmt.setString(1, Utilities.formatDate(sheetdata[i][0], 'Etc/GMT', 'yyyy-MM-dd'));
    stmt.setString(2, sheetdata[i][1]);
    stmt.setString(3, sheetdata[i][2]);
    stmt.setString(4, sheetdata[i][3]);
    stmt.setString(5, sheetdata[i][4]);
    stmt.setString(6, sheetdata[i][5]);
    stmt.setString(7, sheetdata[i][6]);
    stmt.addBatch();
  }
      var batch = stmt.executeBatch();
      conn.commit();
      conn.close();

var end = new Date()
Logger.log('Time elapsed: %sms for %s rows.', end - start, batch.length);
}

推荐答案

发现问题出在新的App Script Runtime V8上.要解决此问题,请将运行时更改回Rhino.为此,请转到查看>显示项目清单",然后在其上显示"runtimeVersion":"V8",将其更改为"runtimeVersion":"STABLE".当前在此问题上存在一个未解决的错误: https://issuetracker.google.com/issues/149413841

Found out that the issue is with the new App Script Runtime V8. For a fix, change your runtime back to Rhino. To do this go to "View > Show project manifest" then where it says "runtimeVersion": "V8" change this to be "runtimeVersion": "STABLE". There is currently an open bug on this issue here: https://issuetracker.google.com/issues/149413841

这篇关于由于超时或客户要求而取消的对帐单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆