Share Point
asked on
ORA-12560: TNS:protocol adapter error
Hi Exeprts,
I have Node.js and trying to read data directly from oracle database. I do have connection string. I am able to access those database through SQL Developer but when i use Node.js it's throwing the error " ORA-12560: TNS:protocol adapter error". I have used Oracledb module.
Can you please help me to identify the probelm?
I have Node.js and trying to read data directly from oracle database. I do have connection string. I am able to access those database through SQL Developer but when i use Node.js it's throwing the error " ORA-12560: TNS:protocol adapter error". I have used Oracledb module.
Can you please help me to identify the probelm?
var express = require("express");
var object_to_xml = require("object-to-xml");
var router = express.Router();
var db;
var dataQuery = "Select * from COUNTRY";
//console.log(dataQuery);
//router.use("/", function (req, res, next) {
var connString =
"(DESCRIPTION = (enable = broken) (ADDRESS = (PROTOCOL = TCP)(HOST = host1)(PORT = 1526))(CONNECT_DATA = (SERVICE_NAME = ABC)))";
var config = { tns: connString, user: "user1", password: "pass1" };
console.log(config);
db = require("oracledb");
db.outFormat = db.OBJECT;
//console.log(config);
db.getConnection(config, function (err, connection) {
if (err) {
console.error(err.message);
return;
}
connection.execute(dataQuery, function (err, results) {
if (err) {
console.error(err.message);
return;
}
console.log(results);
});
});
//});
module.exports = router;
ASKER
Hi,
I am getting below message.
'tnsping' is not recognized as an internal or external command,
operable program or batch file.
I am getting below message.
'tnsping' is not recognized as an internal or external command,
operable program or batch file.
Check if you can access the Oracle server Host:
ping host1
telnet host1 1526
Possibly the Host DNS name isn't good. Look this example: pinssol01.mis.net
Possibly there is firewall that prevents access to the Oracle host and the port 1526
First check the elements of the connection description.
ping host1
telnet host1 1526
Possibly the Host DNS name isn't good. Look this example: pinssol01.mis.net
Possibly there is firewall that prevents access to the Oracle host and the port 1526
First check the elements of the connection description.
you probably need to install the Oracle client matching the target database version (or a greater client verion)
your script is fine, it run fine on my side
your script is fine, it run fine on my side
ASKER
Hi schwertner,
I am able to ping Servername. Below is the message.
Reply from 15.70.68.196: bytes=32 time=62ms TTL=243
Reply from 15.70.68.196: bytes=32 time=62ms TTL=243
Reply from 15.70.68.196: bytes=32 time=62ms TTL=243
Reply from 15.70.68.196: bytes=32 time=62ms TTL=243
When i tried telnet command it's trowing "'telnet' is not recognized as an internal or external command,"
Connection description is good ( I have changed the servername for the question). I am able to connect database through SQL Developer.
I am able to ping Servername. Below is the message.
Reply from 15.70.68.196: bytes=32 time=62ms TTL=243
Reply from 15.70.68.196: bytes=32 time=62ms TTL=243
Reply from 15.70.68.196: bytes=32 time=62ms TTL=243
Reply from 15.70.68.196: bytes=32 time=62ms TTL=243
When i tried telnet command it's trowing "'telnet' is not recognized as an internal or external command,"
Connection description is good ( I have changed the servername for the question). I am able to connect database through SQL Developer.
ASKER
Hi,
I have downloaded Basic and SDK from below url.
https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html
I have created the folder C:\Oracle\instantclient and copy all the files from both folders. Also changed the PATH environment variable.
Did i miss any other installation package?
I have downloaded Basic and SDK from below url.
https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html
I have created the folder C:\Oracle\instantclient and copy all the files from both folders. Also changed the PATH environment variable.
Did i miss any other installation package?
what do you get with the following command :
node -p "process.arch"
ASKER
x64
"'telnet' is not recognized as an internal or external command,"
you need to install the telnet client (which is not recommended on a server), with "add program" GUI or command line :
dism /online /Enable-Feature /FeatureName:TelnetClient
ASKER
Hi,
Now i am getting different error when i run the same code.
Error: [Error: ORA-12541: TNS:no listener] { errorNum: 12541, offset: 0 }
Now i am getting different error when i run the same code.
Error: [Error: ORA-12541: TNS:no listener] { errorNum: 12541, offset: 0 }
as schwertner suggest it, test your listener with a telnet to the right server and port
ASKER
Hi,
I have installed Oracle Database Express Edition (XE) Release 18.4.0.0.0 (18c) from below website.
https://www.oracle.com/database/technologies/xe-downloads.html
It's a local oracle database on my AWS workspace (WIndows 10). I am able to connect this database by SQL developer but not with node.js. It's throwing same error "ORA-12560: TNS:protocol adapter error".
I have installed Oracle Database Express Edition (XE) Release 18.4.0.0.0 (18c) from below website.
https://www.oracle.com/database/technologies/xe-downloads.html
It's a local oracle database on my AWS workspace (WIndows 10). I am able to connect this database by SQL developer but not with node.js. It's throwing same error "ORA-12560: TNS:protocol adapter error".
var express = require("express");
var object_to_xml = require("object-to-xml");
var router = express.Router();
var db;
var dataQuery = "Select * from Help";
//console.log(dataQuery);
//router.use("/", function (req, res, next) {
//process.env['PATH'] = 'c:/oracle/instantclient;' + process.env['PATH'];
var connString =
"(DESCRIPTION = (enable = broken) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = XEPDB1)))";
var config = { tns: connString, user: "SYSTEM", password: "admin" };
//console.log(config);
db = require("oracledb");
db.outFormat = db.OBJECT;
//console.log(config);
db.getConnection(config, function (err, connection) {
if (err) {
console.error(err.message);
return;
}
connection.execute(dataQuery, function (err, results) {
if (err) {
console.error(err.message);
return;
}
console.log(results);
});
});
//});
module.exports = router;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi ,
I really apologies. There was a problem with my package.json file. I installed Oracledb package again and tried it. I am able to connect local database. For remote database it's throwing error "ORA-01017: invalid username/password; logon denied" since i use same credential for SQL developer.
Again thank you so much for your time.
I really apologies. There was a problem with my package.json file. I installed Oracledb package again and tried it. I am able to connect local database. For remote database it's throwing error "ORA-01017: invalid username/password; logon denied" since i use same credential for SQL developer.
Again thank you so much for your time.
so it's fixed?
ASKER
Yes, It's fixed. At least i am not getting any error regarding TNS. I am getting "ORA-01017: invalid username/password; logon denied" with correct credential for remote database. I will take a look that.
Thank you so much for your time and help.
Thank you so much for your time and help.
ORA-01017: invalid username/password; logon denied
use sqlplus to "debug" this using the same login, password and SID used in your file.
ASKER
Hi,
I am using same ServiceName , Username and password for SQLPlus and Node.js. Even tried couples of connections too but same error.
I am using same ServiceName , Username and password for SQLPlus and Node.js. Even tried couples of connections too but same error.
you connString say : HOST = localhost instead your amazon ec2/rds address
ASKER
Thank You Sir. I will take a look later but i am closing the question for now.
Thank you all for the help.
Thank you all for the help.
ASKER
There was a problem with Package.Jason file. But expert comment helped me to find root of cause. Thank you all.
Open in new window