Connecting to a remote Oracle DB with Nodejs through Oracledb Driver

梦想与她 提交于 2019-12-06 12:07:33

put the complete connection address in the connectString variable

{ user : process.env.ORACLE_USER, password : process.env.ORACLE_PASSWORD, connectString : "(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))(CONNECT_DATA =(SID= ORCL)))" }

To technically answer the question, set the environment variable TNS_ADMIN. Then node-oracledb (and other OCI-based language APIs like Python cx_Oracle, PHP OCI8, Ruby ruby-oci8 etc) will look for $TNS_ADMIN/tnsnames.ora.

I have a similar case where I have two VM on azure. One for Oracle12c DB and other is for nodejs oracledb package with Oracle client-side libraries. This is my connection string from client-side to connect with remote DB.

module.exports = {
  user          : process.env.NODE_ORACLEDB_USER || "hr",
  password      : process.env.NODE_ORACLEDB_PASSWORD || "welcome",
  connectString : process.env.LOCAL || "myipaddress:1521/servicename",
};
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!