Skip to Main Content

Programming Languages & Frameworks

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Node Js to Oracle Connection with TNS connection string

user11148886Mar 3 2016 — edited Mar 4 2016

Hi ,

I am trying to connection to a remote Oracle server from Node Js code . I am trying to use TNS connection string instead of conventional configuration connection string. I am using following but getting "ORA-01017: invalid username/password; logon denied" error. Could anyone help me with this error? Following is my code for connection

var express = require('express');

var object_to_xml = require('object-to-xml');

var router = express.Router();

var db;

var  dataQuery= "select * from movie";

router.use('/', function(req, res, next) {

  var connString = "(DESCRIPTION =(LOAD_BALANCE = ON)(FAILOVER = ON)(ADDRESS =(PROTOCOL = TCP)(HOST = server1)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = server2)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE)(FAILOVER_MODE=(TYPE=SELECT)(METHOD = BASIC))))";

  var config = { "tns": connString,"user": "scott", "password": "tiger" };

  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;

  }

  res.send(object_to_xml(results));

  });

  });

});

module.exports = router;

but when I am trying to connect to any of the server mentioned in the host  from SQLDeveloper then I am able to connect correctly.

Comments

Answer

rqEval can accept non-numeric types as input.

In your example, 'select 1 "Industry" forces a returned numeric value.  It fails because the data returned contains 1 non-numeric column. The output doesn't match the specification in the SQL provided, and an error is returned.

Instead, use cast to return as varchar as follows:

SQL> select * from table(rqEval(

        NULL,

        'select cast(''Industry'' as varchar2(8)) "Industry" from dual',

       'Test'));

Returns:

1 Text

Marked as Answer by 3631507 · Sep 27 2020
1 - 1

Post Details

Added on Mar 3 2016
2 comments
13,940 views