0
votes

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.

1
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. - Malice
This is a TNS related error rather than a 'oracledb' error - Malice
I am able to connect to "Admissions" alias successfully through SQL Developer upon defining "Connecting type" as TNS - PHP Developer
ADMISSIONS or Admissions ? And in which file have you defined the alias. - Malice
"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 - PHP Developer

1 Answers

0
votes

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