Connect to OracleDB from NodeJS?

thehanna

Brian Hanna

Posted on July 2, 2019

Connect to OracleDB from NodeJS?

I currently use Java ADF REST web services to access the data in a bunch of legacy Oracle databases. It's slow, static, one dimensional, and a huge pain point. I use NodeJS for the application servers, so I was hoping to implement some cleaner, more dynamic APIs to interface with the Oracle databases there.

However, I cannot, for the life of me, figure out how to connect to this database from NodeJS. I can get to the database via SQL Developer. I have a Data Source set up in the integrated WebLogic Server that ships with JDeveloper for the current web services that (seemingly) uses all the same information. I have all the information: the hostname, the username, the password, the port, and the SID. I've gotten the InstantClient installed and added to my PATH on my Mac. No configuration of this information seems to work properly in NodeJS. I'm using node-oracledb version 3.1.2 on NodeJS v10.15.3. My connection object looks like this:

{
  user: 'my_username',
  password: 'my_password',
  connectString: 'app.company.com:port:database_name'
}

The above configuration results in the error:

Error: ORA-12545: Connect failed because target host or object does not exist

So something is clearly wrong with my connection string. I have tried multiple permutations on the connectString as well, including:

  • app.company.com:port/database_name
    • Error: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
  • jdbc:oracle:thin:@app.company.com:port:database_name
    • Works with SQL Developer and WebLogic Server Data Source, but produces error ORA-12514 when used in NodeJS

I'm grasping at straws. All of the information I've found has been so dense as to be basically useless. I'm not a Java developer. I've never worked heavily with Oracle databases before. I'm sure there is some strange, arcane configuration thing that I'm missing, but I don't even know what questions to ask. Literally any additional information would be incredibly useful.

💖 💪 🙅 🚩
thehanna
Brian Hanna

Posted on July 2, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related