在ubuntu上使用节点oracle时的分段



我正在使用带有以下代码的node oracle模块(来自node oracle文档):

var oracle = require("oracle");
oracle.connect({ "hostname": "192.168.1.120/orcl", "user": "USER", "password": "PASS" }, function(err, connection) {
  if(err){ console.log("Connect err:" + err); }
  if(connection){ console.log("Connection:" + connection); }
  // selecting rows
connection.execute("SELECT nickname FROM users WHERE nickname = :1", ['luc'], function(err, results) {
  console.log("execution");
  console.log("RESULTS:" + results);
  console.log("Err:" + err);
});
connection.setAutoCommit(true);
connection.commit(function(err) {
  console.log("commiting");
  // transaction committed
});
connection.rollback(function(err) {
  console.log("rollback");
  // transaction rolledback
});
connection.close(); // call this when you are done with the connection
});

这给了我不同的错误信息:

$ node test_node_oracle.js 
Connection:[object Connection]
rollback
commiting
execution
RESULTS:undefined
Err:Error: ORA-24324: service handle not initialized

有时它也会给出:

$ node test_node_oracle.js 
Connection:[object Connection]
Segmentation fault

或者:

$ node test_node_oracle.js 
Connection:[object Connection]
commiting
rollback
execution
RESULTS:undefined
Err:Error: ORA-32102: invalid OCI handle

sqlplus访问运行良好:

$sqlplus用户/PASS@192.168.1.120/orcl

SQL*Plus:Release 11.2.0.3.0 2012年3月12日星期一15:18:18 生产

版权所有(c)19822011,Oracle。保留所有权利。

连接到:Oracle Database 11g Enterprise Edition 11.2.0.1.0版-生产版具有分区、OLAP、数据挖掘和实际应用程序测试选项

SQL>

connection.close(); // call this when you are done with the connection

我认为这个get调用得太早了,因为node.js(事件循环)中的所有语句都是非阻塞的。您可能应该将它封装在commitrollback中的适当回调中。您还应该将所有代码封装在connection回调中

oracle.connect({ "hostname": "192.168.1.120/orcl", "user": "USER", "password": "PASS" }, function(err, connection) {
// wrap all your code inside of this.
}

最新更新