我收到一条错误消息:在watson中设置上下文变量时,无法在null上找到属性或字段“ dal”

时间:2019-05-14 23:42:16

标签: watson-assistant

我正在使用Cloud Functions将数据插入表中。我从DB2 Warehouse复制粘贴了连接凭证,并使用它们设置了上下文变量。

在Watson之外,所有功能都可以正常工作。

"dsn": "DATABASE=BLUDB;HOSTNAME=dashdb-entry-yp-dal09 08.services.dal.bluemix.net;

我应该能够连接并将数据插入表中。 请帮忙。

这是我使用的代码(由教程提供):

function insertClient(dsn, eventValues) {
  try {
    var conn = ibmdb.openSync(dsn);
    // The timestamp value is derived from date and time values passed in
    var data = conn.querySync("insert into client (name) values('test')", eventValues);
    conn.closeSync();
    return {
      result: data
    };
  } catch (e) {
    return {
      dberror: e
    }
  }
}

function main({
  eventValues,
  __bx_creds: {
    dashDB: {
      dsn
    }
  }
}) {
  return insertClient(dsn, eventValues);
}

DB2提供的凭据:

{   “主机名”:“ dashdb-entry-yp-dal09-08.services.dal.bluemix.net”,   “ password”:“”,   “ https_url”:“ https://dashdb-entry-yp-dal09-08.services.dal.bluemix.net:8443”,   “端口”:50000,   “ ssldsn”:“数据库= BLUDB;主机名= dashdb-entry-yp-dal09-08.services.dal.bluemix.net; PORT = 50001; PROTOCOL = TCPIP; UID = dash100113; PWD =;安全性= SSL;”,   “ host”:“ dashdb-entry-yp-dal09-08.services.dal.bluemix.net”,   “ jdbcurl”:“ jdbc:db2://dashdb-entry-yp-dal09-08.services.dal.bluemix.net:50000 / BLUDB”,   “ uri”:“ db2:// dash100113:Qs1_I_5eZUkl@dashdb-entry-yp-dal09-08.services.dal.bluemix.net:50000 / BLUDB”,   “ db”:“ BLUDB”,   “ dsn”:“ DATABASE = BLUDB;主机名= dashdb-entry-yp-dal09-08.services.dal.bluemix.net; PORT = 50000; PROTOCOL = TCPIP; UID = dash100113; PWD =;”,   “用户名”:“ dash100113”,   “” ssljdbcurl“:” jdbc:db2://dashdb-entry-yp-dal09-08.services.dal.bluemix.net:50001 / BLUDB:sslConnection = true;“ }

0 个答案:

没有答案