ibm_db\lib\odbc.js outputs the following: self.odbc = (options.odbc) ? options.odbc : new odbc.ODBC();

326 views
Skip to first unread message

Robert Loredo

unread,
May 30, 2015, 1:42:44 PM5/30/15
to node-...@googlegroups.com
Hello,

  I am using the ibm-db.js node module to access a remote IBM DB2 table. I have a local install of IBM DB2 Personal Connect v10 on my windows 7 machine.
When trying to connect to the remote system using the following connection string

I get the following output but no results.
\node_modules\ibm_db\lib\odbc.js:81
self.odbc = (options.odbc) ? options.odbc : new odbc.ODBC();


any ideas why I am unable to read the results?

Below is a snippet of what I am trying to do.

var ibmdb = require('ibm_db');
ibmdb.open("DRIVER=com.ibm.db2.jcc.DB2Driver;DATABASE=dbname;HOSTNAME=hostname;UID="+user+";PWD="+pass+";PORT=446", function (err,conn) {
      if (err) return console.log("Error found: \n"+ err);
      else{
          console.log("No error returned... calling query.");
          conn.query(query, function (err, data) {
                if (err) console.log(err);
                else {
                    console.log("output returned:");
                    console.log(data);
                }
             
                conn.close(function () {
                  console.log('done');
                });
              });
      }
    });

Attached is a screenshot of what I get from the command line when I run this using:
node ./IBM-DB.js

Im using node v 0.10.35 on eclipse juno

Thanks!
Robert
ibm-db_odbc issue.jpg

bimaljha

unread,
May 30, 2015, 2:00:18 PM5/30/15
to node-...@googlegroups.com, robert...@gmail.com
Hi Robert,

node-ibm_db is an ODBC driver and hence, it does not uses JCC driver. Your connection string should be as below:

ibmdb.open("DRIVER={DB2};DATABASE=<dbname>;HOSTNAME=<hostname>;UID="+user+";PWD="+pass+";PORT=446", function (err,conn)

Thanks,
Bimal

vishwajeet gupta

unread,
Feb 22, 2017, 8:28:04 AM2/22/17
to node-ibm_db


On Saturday, May 30, 2015 at 11:12:44 PM UTC+5:30, Robert Loredo wrote:
Hello,

  I am using the ibm-db.js node module to access a  ibm bluw mix .
When trying to connect to the using the following connection string

I get the following output but no results.
\node_modules\ibm_db\lib\odbc.js:146
 
 self.odbc = (options.odbc) ? options.odbc : ((ENV) ? ENV : new odbc.ODBC());


self.odbc = (options.odbc) ? options.odbc : ((ENV) ? ENV : new odbc.ODBC());
  if(!ENV) ENV = self.odbc;
  self.queue = new SimpleQueue();
  self.fetchMode = options.fetchMode || null;
  self.connected = false;
  

any ideas why I am unable to read the results?

Below is a snippet of what I am trying to do.

var ibmdb = require('ibm_db');
var db2;
var db2Srf;
var hasConnect = false;
//Staging DB
if ( hasConnect == false ) {

   db2 = {
        /* db: "BLUDB",
        "hostname": "bluemix05.bluforcloud.com",
        //hostname: "dashdb-entry-yp-dal09-09.services.dal.bluemix.net",
        port: 50000,
        username: "dash107663",
        password: "orfiLgWoYvDr"
        db2 = { */
        db: "BLUDB",
        hostname: "dashdb-entry-yp-dal09-09.services.dal.bluemix.net",
        port: 50000,
        username: "dash100460",
        password: "oQzgZ5SWNhhU"

     };
     
     db2Srf = {
        hostname     : "b28aeirdb01.in.ibm.com",
        username     : "vishwa",
        password : "pHx7mExG",
        port     :  50014,
        db : "REPSET"

     };
}



var connString = "DRIVER={DB2};DATABASE=" + db2.db + ";UID=" + db2.username + ";PWD=" + db2.password + ";HOSTNAME=" + db2.hostname + ";port=" + db2.port;
var connString1 = "DRIVER={DB2};DATABASE=" + db2Srf.db + ";UID=" + db2Srf.username + ";PWD=" + db2Srf.password + ";HOSTNAME=" + db2Srf.hostname + ";port=" + db2Srf.port;

var connection;
console.log("ConnectionString::" + connString);
    ibm_db.open(connString, function(err, conn) {
        if (err ) {
            console.log("ConnectionError->" + JSON.stringify(err));
        }
        else {
            connection=conn;   
            console.log("ConnectionSuccessful->" + JSON.stringify(err));
        }
});
var connection1;
console.log("ConnectionString::" + connString1);
    ibm_db.open(connString1, function(err, conn1) {
        if (err ) {
            console.log("ConnectionError->" + JSON.stringify(err));
        }
        else {
            connection1=conn1;   
            console.log("ConnectionSuccessful1->" + JSON.stringify(err));

bimaljha

unread,
Feb 23, 2017, 5:00:46 AM2/23/17
to node-ibm_db
Hi Robert,

In your script, you are using "ibm_db.open()" API, but first line of your script has defined ibmdb and not ibm_db. Please update your first line as below and run your script. It should work as it is working find for me.

var ibm_db = require('ibm_db');

Following the run result for me:

> node bmix.js 

ConnectionString::DRIVER={DB2};DATABASE=BLUDB;UID=dash100460;PWD=oQzgZ5SWNhhU;HOSTNAME=dashdb-entry-yp-dal09-09.services.dal.bluemix.net;port=50000

ConnectionString::DRIVER={DB2};DATABASE=REPSET;UID=vishwa;PWD=pHx7mExG;HOSTNAME=b28aeirdb01.in.ibm.com;port=50014

ConnectionSuccessful1->undefined

ConnectionSuccessful->undefined

>

Thanks,
Bimal Jha

Craig Wilson

unread,
May 8, 2017, 7:26:25 AM5/8/17
to node-ibm_db, robert...@gmail.com
Hi Bimal,

I have just install node v6 and ibm_db module on Windows 10. My connection string is defined as below but I'm getting this same error.

self.odbc = (options.odbc) ? options.odbc : ((ENV) ? ENV : new odbc.ODBC());
                                                             ^
[object Object]

I basically copied the sample code from ibm_db npm.

Not sure where I have gone wrong.

Regards,
Craig

bimaljha

unread,
May 10, 2017, 12:55:55 AM5/10/17
to node-ibm_db, robert...@gmail.com
Check the fix here: https://github.com/ibmdb/node-ibm_db/issues/168#issuecomment-300155925

Thanks and Regards,
Bimal Jha
Reply all
Reply to author
Forward
0 new messages