简体   繁体   中英

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

I want to connect to Oracle 12c remote. I have two vms. One with node package oracledb and oracle client libraries basic and sdk. Other vm has 12c installed. I tried chaning localhost to vm ip address in listener.ora files but no success. Can anyone guide what exactly I need to do so I can connect to remote oracle 12c using oracledb npm package. 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). For both, I use NAT networking.

  • I set up 'port forwarding' in the DB VM so that the Oracle DB port (typically 1521) is available to the host OS. This can be done in the 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. For me, this gateway is 10.0.2.2 so my application connectString is like 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

Of course, if you aren't using VirtualBox , your solution will be different....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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