我尝试将oracle DB与nodejs连接,并且得到如下消息:
ORA-12560:TNS:协议适配器错误
这是我的代码:
oracledb.getConnection(
{
user:"user",
password:"password",
ConnectString:"IP:PORT/instance_name"
},
function(err, connection) {
if (err) {
console.error(err.message);
return;
}
console.log('Connection was successful!');
connection.close(
function(err) {
if (err) {
console.error(err.message);
return;
}
});
});
答案 0 :(得分:0)
请检查是否已将oracle环境设置为本地计算机并测试此代码
var oracleConnection = require('knex')({
client: 'oracledb',
native: false,
connection: {
user: 'username',
password: 'password',
connectString: 'connectionstring'
},
pool: {
max: 5,
min: 1,
idle: 10000
}
});
oracleConnection.insert({
ID: '1',
NAME: 'oracle'
}).into('TEST_TABLE')
.then(function() {
console.log('success')
// pg1.commit()
})
.catch(function(e) {
console.log(e.stack)
});