3

错误:ORA-32102:无效的 OCI 句柄

var oracle = require('oracle');

oracle.connect({ "hostname": "hostname", "user": "user", "password": "password" },
  function(err, connection) {

    if(err){ console.log("Connect err:" + err); }
    if(connection){ console.log("Connection:" + connection); }

    console.log(connection);
    console.log("........");

    // selecting rows
    connection.execute("SELECT * FROM AUTOLOAN_MASTER WHERE RELIGION = :1", ['R'], 
      function(err, results) {
    if (err) {
      console.log('Failed to query table in Oracle: '+ err);
     req.results = null;
    }
    console.log(req);
    console.log(req.results);
      });

      connection.close();
   });

Oracle 软件包已安装在 ubuntu 中。出现以下错误:错误:ORA-32102:无效的 OCI 句柄

4

1 回答 1

4

刚遇到同样的问题。将 connection.close 移动到您的执行函数中。因为这是 Node 并且事情是非阻塞运行的,所以它会在结果发回之前关闭您的连接。

var oracle = require('oracle');

oracle.connect({ "hostname": "hostname", "user": "user", "password": "password" },
  function(err, connection) {

    if(err){ console.log("Connect err:" + err); }
    if(connection){ console.log("Connection:" + connection); }

    console.log(connection);
    console.log("........");

    // selecting rows
    connection.execute("SELECT * FROM AUTOLOAN_MASTER WHERE RELIGION = :1", ['R'], 
      function(err, results) {
        if (err) {
          console.log('Failed to query table in Oracle: '+ err);
          req.results = null;
        }
        console.log(req);
        console.log(req.results);
        connection.close(); // Moved inside execute callback
   });
});
于 2013-04-16T23:03:34.473 回答