IBM / nodejs-idb-connector

A JavaScript (Node.js) library for communicating with Db2 for IBM i, with support for queries, procedures, and much more. Uses traditional callback-style syntax
MIT License
37 stars 23 forks source link

The Dbconn Object is not connected #125

Closed GautierFR closed 4 years ago

GautierFR commented 4 years ago

Hello,

There is my contexte : node.js version : v12.18.2 idb-connector version :

-- itoolkit@1.0.0 +-- idb-connector@1.2.9 -- idb-pconnector@1.0.8 -- idb-connector@1.2.9 deduped

IBM i version : V7R2

I obtain the error with the first sample of idb-connector (in my file idb_sql.js) :

 const {dbconn, dbstmt} = require('idb-connector');

    const sSql = 'SELECT STATE FROM QIWS.QCUSTCDT';
    const connection = new dbconn();
    connection.conn('*LOCAL');
    const statement = new dbstmt(connection);

    statement.exec(sSql, (x) => {
      console.log(JSON.stringify(x));
      statement.close();
      connection.disconn();
      connection.close();
    });

The error is : `# node idb_sql.js Cannot convert between code set (CCSID 1208) and code set (CCSID 297) Cannot convert between code set (CCSID 819) and code set (CCSID 297) ERROR: SQLALLOCENV(-1)Cannot convert between code set (CCSID 819) and code set (CCSID 297) Cannot convert between code set (CCSID 819) and code set (CCSID 297) /myapp/idb_sql.js:7 const statement = new dbstmt(connection); ^

Error: SQLSTATE=PAERR SQLCODE=8013 The Dbconn Object is not connected at Object. (/myapp/idb_sql.js:7:19) at Module._compile (internal/modules/cjs/loader.js:1138:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) at Module.load (internal/modules/cjs/loader.js:986:32) at Function.Module._load (internal/modules/cjs/loader.js:879:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 # `

Important point : i'm in a chrooted environment. I created the environment by following this article : https://www.ibmsystemsmag.com/Power-Systems/07/2019/getting-started-ifs-containers

# chroot_setup node12

And I enter the chroot with : # chroot /QOpenSys/gdumas_chroots/node12 /QOpenSys/usr/bin/sh

And I configure the PATH

# PATH=/QOpenSys/pkgs/lib/nodejs12/bin:/QOpenSys/pkgs/bin:$PATH

And I start my idb_sql.js script.

Node version 10 is installed on this LPAR, and the simple example of idb-connector works fine outside the chroot.

Thanks you for your help.

GautierFR commented 4 years ago

Problem fixed with adding on my chroot nodejs12 the "nls" part : chroot_setup /QOpenSys/gdumas_chroots/node12 nls

Solution found in chat from https://ibmioss.ryver.com/