简体   繁体   English

使用 Node.js oracledb 连接到远程 Oracle Database 2c

[英]Connect to remote Oracle Database 2c using Node.js oracledb

I want to connect to Oracle 12c remote.我想连接到 Oracle 12c 远程。 I have two vms.我有两个虚拟机。 One with node package oracledb and oracle client libraries basic and sdk.一个带有节点包 oracledb 和 oracle 客户端库 basic 和 sdk。 Other vm has 12c installed.其他虚拟机安装了 12c。 I tried chaning localhost to vm ip address in listener.ora files but no success.我尝试在 listener.ora 文件中将 localhost 更改为 vm ip 地址,但没有成功。 Can anyone guide what exactly I need to do so I can connect to remote oracle 12c using oracledb npm package.任何人都可以指导我到底需要做什么,以便我可以使用 oracledb npm 包连接到远程 oracle 12c。 See below for the code代码见下方

var oracledb = require('oracledb');
var dbConfig = require('./dbconfig.js');

oracledb.getConnection(
  {
    user          : user,
    password      : password,
    connectString : connectString??
  },

Thanks谢谢

I often run Node.js in one VirtualBox VM and connect to a database running in a second VirtualBox VM (both hosted on the same MacBook).我经常在一个 VirtualBox VM 中运行 Node.js,并连接到在第二个 VirtualBox VM(都托管在同一台 MacBook 上)中运行的数据库。 For both, I use NAT networking.对于两者,我都使用 NAT 网络。

  • I set up 'port forwarding' in the DB VM so that the Oracle DB port (typically 1521) is available to the host OS.我在 DB VM 中设置了“端口转发”,以便主机操作系统可以使用 Oracle DB 端口(通常为 1521)。 This can be done in the VBox GUI.这可以在 VBox GUI 中完成。 To keep it easy, I use the same port number on both host & guest sides.为方便起见,我在主机端和来宾端使用相同的端口号。

  • In the Node.js VM, I use the IP address of the NAT gateway for the connect string.在 Node.js VM 中,我使用 NAT 网关的 IP 地址作为连接字符串。 For me, this gateway is 10.0.2.2 so my application connectString is like 10.0.2.2/orclpdb对我来说,这个网关是 10.0.2.2 所以我的应用程序connectString就像10.0.2.2/orclpdb

There are screen shots and details in my blog post https://blogs.oracle.com/opal/the-easiest-way-to-install-oracle-database-on-apple-mac-os-x我的博客文章中有屏幕截图和详细信息https://blogs.oracle.com/opal/the-easiest-way-to-install-oracle-database-on-apple-mac-os-x

Of course, if you aren't using VirtualBox , your solution will be different....当然,如果您不使用VirtualBox ,您的解决方案会有所不同....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM