压缩包下载

创建文件夹network/admin

文件夹下创建2个文件

写入如下内容

tnsnames.ora

MYDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ip)(PORT = 端口号))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = 数据库名称)
    )
  )

sqlnet.ora

SQLNET.AUTHENTICATION_SERVICES= (NONE)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

环境变量

path

OCI_INC_DIR

OCI_LIB_DIR

下载模块

npm install oracledb

测试demo

npm 

const oracledb = require('oracledb');  
  
oracledb.getConnection({  
  user: "账号",  
  password: "密码",  
  connectString: "ip:端口号/数据库名称" 
}, function(err, connection) {  
  if (err) {  
    console.error(err.message);  
    return;  
  }  
  else{
    console.info("conn:",connection);
    connection.execute(
      "SELECT * FROM 表名 WHERE ID = 'ID号'",
      function(err, result) {
        if (err) {
          console.error(err.message);
          return;
        }
        console.log(result.rows);
      });}
});

压缩包地址

https://blog.csdn.net/qq_50935441/article/details/140100084?spm=1001.2014.3001.5502

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐