db.dbconn is not a constructor

Issue #17 closed
Brian Jerome created an issue

Since the beginning of the month I've had an issue with creating a db connection. The latest level 6 patches/open source group PTFs are installed. Currently, I'm running Node v6.12.2 with the shipped db2a.js and db2ia.node. I'm wondering if one of the newer patches caused something to break..

JS Code:

const db2a = require('/QOpenSys/QIBM/ProdData/OPS/Node6/os400/db2i/lib/db2a');

let conn = new db2a.dbconn(),
    stmt,
    sql = 'SELECT ...';

conn.conn('*LOCAL');

stmt = new db2a.dbstmt(conn);

stmt.exec(sql, (result) => {
    //handle result
    stmt.close();
    conn.disconn();
    conn.close();
});

Trying to run this has been giving me this error.

1-31-2018 10-03-36 AM.png

db2a.dbstmt also has the same error.

Is there a newer patch that exists or is being worked on that would fix this? Has anyone else run into this issue?

I've tried a few ways of recompiling the db2ia.node file but haven't gotten gmake installed yet. I'm not sure even if recompiling would fix it -- my other option I'm considering is a clean re-install of Node v6.

Comments (8)

  1. Brian Jerome reporter

    Attempting to reinstall Node6 and all the open source tools to see if something was corrupted.

  2. mengxumx Account Deactivated

    Hello Brian, You may try to reinstall PTF SI66497 to see if it works.

    And you can also try to download the pre-compiled addon using --

    npm -g i idb-connector
    

    and replace require('/QOpenSys/.../db2a') with require('idb-connector') in your code.

    If node reports cannot find module 'idb-connector', you can set the searching path by --

    NODE_PATH=/QOpenSys/QIBM/ProdData/OPS/Node6/lib/node_modules
    export NODE_PATH
    
  3. Brian Jerome reporter
    • changed status to open

    @mengxumx The open source tools (up to Group PTF SF99123 - Level 5) were reinstalled (as well as PTF SI66497 applied). I was now able to install the idb-connector package to /QOpenSys/QIBM/ProdData/OPS/Node6/lib/node_modules. I tried running the test.js but I am still getting the same issue.

    2-7-2018 11-37-06 AM.png

  4. mengxumx Account Deactivated

    @bjerome Would you check your effective node version (node -v) and below files' status please?

    bash-4.3$ ls -l /QOpenSys/QIBM/ProdData/OPS/Node6/os400/db2i/lib/db2a.js
    -rw-r--r--    1 qsys     0             65557 Dec 12 13:06 /QOpenSys/QIBM/ProdData/OPS/Node6/os400/db2i/lib/db2a.js
    bash-4.3$ ls -l /QOpenSys/QIBM/ProdData/OPS/Node6/os400/db2i/bin/db2ia.node
    -rwxr-xr-x    1 qsys     0           4588457 Dec 12 13:06 /QOpenSys/QIBM/ProdData/OPS/Node6/os400/db2i/bin/db2ia.node
    bash-4.3$ node /QOpenSys/QIBM/ProdData/OPS/Node6/lib/node_modules/idb-connector/test/test.js
    Execute A.
    Execute A Done. Row Count: 12
    
  5. Brian Jerome reporter

    @mengxumx Below I have run the same commands (added npm -v too):

    -bash-4.3$ node -v
    v6.12.2
    -bash-4.3$ npm -v
    3.10.10
    -bash-4.3$ ls -l /QOpenSys/QIBM/ProdData/OPS/Node6/os400/db2i/lib/db2a.js
    -rw-r--r--    1 qsys     0             65557 Dec 12 00:06 /QOpenSys/QIBM/ProdData/OPS/Node6/os400/db2i/lib/db2a.js
    -bash-4.3$ ls -l /QOpenSys/QIBM/ProdData/OPS/Node6/os400/db2i/bin/db2ia.node
    -rwxr-xr-x    1 qsys     0           4588457 Dec 12 00:06 /QOpenSys/QIBM/ProdData/OPS/Node6/os400/db2i/bin/db2ia.node
    -bash-4.3$ echo $PATH
    /QOpenSys/QIBM/ProdData/OPS/Node6/bin:/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin
    -bash-4.3$ node /QOpenSys/QIBM/ProdData/OPS/Node6/lib/node_modules/idb-connector/test/test.js
    /QOpenSys/QIBM/ProdData/OPS/Node6/lib/node_modules/idb-connector/test/test.js:4
    var dbconns = new dba.dbconn();
                  ^
    
    TypeError: dba.dbconn is not a constructor
        at Object.<anonymous> (/QOpenSys/QIBM/ProdData/OPS/Node6/lib/node_modules/idb-connector/test/test.js:4:15)
        at Module._compile (module.js:570:32)
        at Object.Module._extensions..js (module.js:579:10)
        at Module.load (module.js:487:32)
        at tryModuleLoad (module.js:446:12)
        at Function.Module._load (module.js:438:3)
        at Module.runMain (module.js:604:10)
        at run (bootstrap_node.js:383:7)
        at startup (bootstrap_node.js:149:9)
        at bootstrap_node.js:496:3
    -bash-4.3$
    
  6. Brian Jerome reporter

    @mengxumx We were able to reinstall all the tools on another partition running AIX 7.1 and that is working.

    $ node test
    Execute A.
    Execute A Done. Row Count: 12
    Execute B.
    Execute B Done. Row Count: 12
    Test Async in callback.
    Execute A.
    Execute A Done. Row Count: 12
    Execute B.
    Execute B Done. Row Count: 12
    Test Async concurrently.
    Execute A.
    Execute B.
    Execute A Done. Row Count: 12
    Execute B Done. Row Count: 12
    
  7. Log in to comment