1
votes
  1. I have Linux Enterprise Server 10 SP2(x86_64) - Kernel 2.6.16.60-0.21-smp.
  2. I have IBM Informix Dynamic Server Version 11.10.FC1 installed in the above linux server.
  3. I have windows 2008 server with odbc (dns name for eg: eadmin) (IBM INFORMIX 3.80 32 bit) for informix driver installed and XAMPP v3.2.2 installed
  4. I have development PC as windows 7 with odbc (dns name for eg.eadmin) (IBM INFORMIX 3.80 32 bit) for informix driver installed and wamp 2.4 installed as development server.

My Website is running fine both in server and in my development pc (Windows 7).

Now I want to migrate to Node Js, I want

  1. What are the steps to follow in my development machine.?

  2. I tried npm install odbc, npm install ibm_db, npm install win32ole etc.

  3. All gave error. (or i don't know how to install, it require python error or something)

  4. I want to connect Informix server using ODBC dns as I am connecting in PHP seamlessly.

  5. Simple mongoDB, mysql etc connections are working fine but not informix.

1

1 Answers

1
votes

First you should upgrade your Informix products. IDS 11.10 is way too old. ODBC 3.80 is even older (3.80 was included in CSDK 2.70 released in 2002).

New Informix servers (e.g. 12.10.xC11) provide the option to directly connection using the MongoDB driver. Look at:

https://www.ibm.com/developerworks/community/blogs/da95bfce-e0cf-4056-8bc3-2deea450e378/entry/Informix_and_NoSQL_JSON_Wire_Listener_Setup_and_Mongo_Shell?lang=en

With the JSON listener, there is no need to go through an ODBC driver to connect to the IDS server. Uou can use the same NodeJS module that connects to MongoDB.

Still, if you can't upgrade the engine, there are several Informix NodeJS open source drivers, but all of them will require an update version of the Informix ODBC driver and ESQL/C libraries.

https://github.com/OpenInformix/IfxNode/blob/master/LocalBuildWindows.md https://www.npmjs.com/package/informix

Latest ODBC driver is 4.10.xC11.

Wankdander's 'node-odbc' module does work on Windows:

https://github.com/wankdanker/node-odbc

I tested it with the Informix ODBC driver from CSDK 4.10.FC8, and because it uses ODBC standard calls, it may even work with something as old as 3.80.

-------- EDIT -------

Just tested starting from scratch. You will need:

  1. NodeJS (I used latest stable version 8.11.3)
  2. A C compiler (I used Visual Studio 2015, I guess the 'free' Express version will be enough)
  3. Python

The steps are:

Start a session with the compiler environment set:

C:\Program Files (x86)\Microsoft Visual Studio 14.0>d:

D:\Infx>cd infx\nodejs811

D:\Infx\nodejs811>dir
 Volume in drive D is Data750
 Volume Serial Number is F0B7-2E44

 Directory of D:\Infx\nodejs811

21/06/2018  12:26    <DIR>          .
21/06/2018  12:26    <DIR>          ..
12/06/2018  22:43        22,778,520 node.exe
11/02/2018  01:08               702 nodevars.bat
11/02/2018  01:08             8,985 node_etw_provider.man
21/06/2018  12:26    <DIR>          node_modules
11/02/2018  00:08             4,974 node_perfctr_provider.man
11/02/2018  01:08               867 npm
11/02/2018  00:08               483 npm.cmd
12/06/2018  01:50               867 npx
12/06/2018  01:50               483 npx.cmd
               8 File(s)     22,795,881 bytes
               3 Dir(s)  201,607,630,848 bytes free
D:\Infx\nodejs811>

Set the nodeJS environment:

D:\Infx\nodejs811>nodevars.bat
Your environment has been set up for using Node.js 8.11.3 (x64) and npm.
C:\Users\Administrator> 

Install node-gyp (needed for building the odbc module)

C:\Users\Administrator>npm install node-gyp
npm WARN Administrator No description
npm WARN Administrator No repository field.
npm WARN Administrator No README data
npm WARN Administrator No license field.

+ [email protected]
added 1 package in 1.821s

C:\Users\Administrator>

Install the odbc module:

C:\Users\Administrator>npm install odbc

> [email protected] install C:\Users\Administrator\node_modules\odbc
> node-gyp configure build


C:\Users\Administrator\node_modules\odbc>if not defined npm_config_node_gyp (node "D:\Infx\nodejs811\node_modules\npm\no
de_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure build )  else (node "D:\In
fx\nodejs811\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" configure build )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  odbc.cpp
  odbc_connection.cpp
  odbc_statement.cpp
  odbc_result.cpp
    ....
    ....
  dynodbc.cpp
  win_delay_load_hook.cc
  strptime.c
     Creating library C:\Users\Administrator\node_modules\odbc\build\Release\odbc_bindings.lib and object C:\Users\Admi
  nistrator\node_modules\odbc\build\Release\odbc_bindings.exp
  Generating code
  Finished generating code
  odbc_bindings.vcxproj -> C:\Users\Administrator\node_modules\odbc\build\Release\\odbc_bindings.node
  odbc_bindings.vcxproj -> C:\Users\Administrator\node_modules\odbc\build\Release\odbc_bindings.pdb (Full PDB)
npm WARN Administrator No description
npm WARN Administrator No repository field.
npm WARN Administrator No README data
npm WARN Administrator No license field.

+ [email protected]
added 3 packages in 31.827s

C:\Users\Administrator> 

Check it works with a simple js script connecting to an Informix ODBC DSN:

C:\Users\Administrator>type test.js
var db = require('odbc')()
  , cn = "DSN=ids1210;UID=informix;PWD=dummypwd;";

db.open(cn, function (err) {
  if (err) return console.log(err);

  db.query('select * from systables where tabid = 1', [42], function (err, data) {
    if (err) console.log(err);

    console.log(data);

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

C:\Users\Administrator>node test.js
[ { tabname: 'systables',
    owner: 'informix                        ',
    partnum: 1049238,
    tabid: 1,
    rowsize: 500,
    ncols: 26,
    nindexes: 2,
    nrows: 177,
    created: '2017-10-18',
    version: 65831,
    tabtype: 'T',
    locklevel: 'R',
    npused: 7,
    fextsize: 32,
    nextsize: 32,
    flags: 0,
    site: null,
    dbname: null,
    type_xid: 0,
    am_id: 0,
    pagesize: 4096,
    ustlowts: 2018-06-17T00:11:37.000Z,
    secpolicyid: 0,
    protgranularity: ' ',
    statchange: null,
    statlevel: ' ' } ]
done

C:\Users\Administrator>

I don't have ODBC 3.80, I test it with 4.10, but in theory it should work no matter the version of the driver. There was no 64-bit version of ODBC 3.8, so you will need to use the 32-bit version of NodeJS and compile in 32-bit mode.