将Google Form数据复制到Cloud SQL

时间:2018-08-23 10:00:57

标签: jdbc google-apps-script google-cloud-sql google-form

// Connection to Google form
var form = FormApp.openById('*********************************');

// Connection variable
var instanceConnectionName = '*****:*******:*******';
var user = 'root';
var userPwd = '**********';
var db = '********';

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

// Receive form response and replicate to a row in SQL table
function handleFormSubmit( event ) {
  var conn = Jdbc.getConnection(dbUrl, user, userPwd);

  var stmt = conn.prepareStatement('INSERT INTO eform '
      + '(Timestamp, Email, Department, Acknowledge) values (?, ?, ?, ?)');
  stmt.setString(1, event.namedValues['Timestamp']);
  stmt.setString(2, event.namedValues['Email']);
  stmt.setString(2, event.namedValues['Department']);
  stmt.setString(3, event.namedValues['Acknowledge']);
  stmt.execute();

}

我尝试了上面的代码将Google Form数据保存到我的Cloud SQL实例之一,但出现此错误:

enter image description here

知道为什么吗?无论如何,这是正确的方法吗?我相信连接变量中没有拼写错误,而且我卡住了...

0 个答案:

没有答案