0

I am using oracledb in my Node server for connecting to a TNS Connection Alias. This is my code:

const oracledb = require('oracledb');

    oracledb.getConnection(
        {
            user: "test",
            password: "test",
            connectString: "ADMISSIONS"
        },
        function (err, connection) {
            if (err) {
                logger.error("Error is: " + err.message);
                callback(null, err);
                return;
            } else {
                logger.loud("Connection successful!");
            }
});
}

However, I am getting this error:

TNS:could not resolve the connect identifier specified

I am sure my connectString is wrong. Can anyone please help with what should be the value of connectString if I want to connect to a TNS Connection Alias called Admissions ? Please note this is NOT a localhost/XE connection.

13
  • Are you able to connect using this TNS connection alias using other applications, say sqlplus ? This error usually occurs when your entry in TNS entry is wrong/ not consistent with your network. Commented Aug 15, 2017 at 5:04
  • This is a TNS related error rather than a 'oracledb' error Commented Aug 15, 2017 at 5:05
  • I am able to connect to "Admissions" alias successfully through SQL Developer upon defining "Connecting type" as TNS Commented Aug 15, 2017 at 5:06
  • ADMISSIONS or Admissions ? And in which file have you defined the alias. Commented Aug 15, 2017 at 5:09
  • "ADMISSIONS". The alias is defined by our organisation and I dont have access to the file (or system) where it is defined. It just appears in the drop down menu of TNS Connection type in SQL Developer Commented Aug 15, 2017 at 5:13

1 Answer 1

0

The issue was outdated tnsnames.ora file. I copied the latest version of tnsnames.ora file into my /etc directory and the connection is successful. Thanks to @Malice

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.