1

I've followed the instructions: https://www.ibm.com/developerworks/community/blogs/pd/entry/using_ibm_db2_from_node_js4?maxresults=15&page=0&lang=en for a 32-bit install of Ubuntu.

It seems to have installed correctly and I can run require('ibm_db'). Using the sample code provided (nodedb2test.js), no matter what database parameters I use I get the error:

node nodedb2test.js
Test program to access DB2 sample database
*** stack smashing detected ***: node terminated
Aborted (core dumped)

Heres the sample code:

/*require the ibm_db module*/

var ibmdb = require('ibm_db');
console.log("Test program to access DB2 sample database");

ibmdb.open("DRIVER={DB2};DATABASE=testdb;UID=username;PWD=password;HOSTNAME=localhost;port=3000", function(err, conn)

{
        if(err) {
            console.error("error: ", err.message);
           }

});

Also I looks the version of DB2 I need to connect to is version 6. I have installed BM Data Server Driver version 10.5, does this correspond to the version of DB2? It appears below v9.1 drivers are not available.

2
  • I guess your DB2 platform is actually System i? (That's where you could still have version 6.) If so, it's not enough to have just the IBM ODBC/CLI driver, you'll also need something called DB2 Connect to serve as a gateway. Commented Jun 5, 2014 at 12:14
  • I'm encountering the same issue. Have you figured out the solution yet? Commented Jul 29, 2014 at 23:02

2 Answers 2

1

At time of writing this works for me.

C:\Development\Javascript>node -p "process.arch" x64

C:\Development\Javascript>node -p "process.platform" win32

C:\Development\Javascript>node -p "process.version" v14.17.5

C:\Development\Javascript>npm install ibm_db

var ibmdb = require("ibm_db");

const config = require("config");
const hostname = config.get("db2.hostname");
const username = config.get("db2.username");
const password = config.get("db2.password");

ibmdb.open("DRIVER={DB2};DATABASE=bludb;HOSTNAME=" + hostname + ";UID=" + username + ";PWD=" + password + ";PORT=31198;PROTOCOL=TCPIP;SECURITY=SSL", function (err, conn){

  if (err) return console.log(err);

  conn.query("SELECT * FROM orders", function (err, data) {

    if (err) console.log(err);

    console.log(data);

    conn.close(function () {
      console.log('done');
    });

  });

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

1 Comment

this one worked fine for me
0

We can use ibm_db without installing IBM Data Server Driver Package too. ibm_db internally uses DB2 V10.5FP5 ODBC/CLI driver to talk to DB2 server. Please share the platform info and OS version where you have installed ibm_db. In june'14, ibm_db was supported on Linuxppc, AIX and zLinux platforms, but latest release is supporting. If latest driver is not working for you, please open an issue on github.com/ibmdb/node-ibm_db/issues/new . Thanks.

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.