Node-oracledb: ORA-12560: TNS:protocol adapter error when connecting to database

Created on 25 May 2017  路  6Comments  路  Source: oracle/node-oracledb

I read through this issue (https://github.com/oracle/node-oracledb/issues/691) as well as couple others and it did not solve my problem. I am using oracle instant client (client + sdk +sqlplus) 12.2 with the following code:

import oracledb from 'oracledb';

oracledb.getConnection({    
    user: 'appdba',
    password: 'manager',
    // connectionString: '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = server)(PORT = 1521)))(CONNECT_DATA = (SERVICE_NAME = db1))'
    connectionString: 'server1:1521/db1'
    // connectionString: 'db1'
}).then(connection => {
    console.log('Got connection!');
})
.catch(err => {
    console.log(err);
})

my environment variables are set as:

ORACLE_HOME=C:\oracle\instantclient_12_2
OCI_INC_DIR=C:\oracle\instantclient_12_2\sdk\include
OCI_LIB_DIR=C:\oracle\instantclient_12_2\sdk\lib\msvc
TNS_ADMIN=C:\oracle\instantclient_12_2\network\admin

What I tried

  • Connecting with SQLPlus works for me using the credentials and the tnsname
  • Tried to get a stacktrace using err.stack but it returns just Error: ORA-12560: TNS:protocol adapter error
  • The error does not happen immediately upon connect. It seems like it's waiting for ~5-ish seconds before timing out
  • Tried to run node with -verbose and -debug (and wrapped this in an npm task with debug & verbose output) and I can't see anything.

Is there anyway to determine what's wrong or at least print out some debug output to figure things out?

enhancement

Most helpful comment

@ShiraazMoollatjie It's connectString, not connectionString.

All 6 comments

@ShiraazMoollatjie It's connectString, not connectionString.

I have an old note that we should add connectionString as an alias for connectString. A PR is welcome, of course!

@cjbj since you are not really merging those PRs, you can simply ask one of the oracle developers to copy paste the below

connection.js line 97

````js
if (!poolAttrs.connectString) {
poolAttrs.connectString = poolAttrs.connectionString;
}

self._createPool(poolAttrs, function(err, poolInst) {
````

connection.js line 207

````js
if (!connAttrs.connectString) {
connAttrs.connectString = connAttrs.connectionString;
}

self._getConnection(connAttrs, function(err, connInst) {
````

@sagiegurari thanks. I'd like to get some basic test added; we can do that.

@dmcghan That was it!! Not sure where I got connectionString from, but anyway thanks alot!

@sagiegurari the new alias connectionString is now in node-oracledb 2.1.0. Thanks!

Was this page helpful?
0 / 5 - 0 ratings