admin管理员组

文章数量:1022853

we have a project with Node.js that use the ibm_db to connect to the DB2/AS400.

The problem is that it returns the following error:

[SERVER] { Error: [IBM][CLI Driver] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968

[SERVER]

[SERVER]   errors: [],

[SERVER]   error: '[node-odbc] SQL_ERROR',

[SERVER]   message: '[IBM][CLI Driver] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968\r\n',

[SERVER]   state: '42968' }

there Is an alternative way to connect to AS400, from node, js that does not require a license?

This is the code we use for the connection:

"use strict";
var models = require("../../models/index");
var express = require("express");

var db2Route = express.Router();
const ibmdb = require("ibm_db");
//import ibm_db


const opts = [
    'DRIVER={IBM DB2 CLI DRIVER}',
    'DATABASE=*****',
    'PROTOCOL=TCPIP',
    'HOSTNAME=*****',
    'PORT=446',
    'UID=*****',
    'PWD=*****',
    'DBQ=,*USRLIBL'
];




db2Route.route("/").post((req, res) => {

    ibmdb.open(opts.join(';'), (err, conn) => {
        if (err) return console.log(err);

        conn.query("Select * from TBFR0F" ,(err, data) =>{
            if (err) console.log(err);
            else console.log(data);
            conn.close(() => console.log('done'));
        });
    });
});

we have a project with Node.js that use the ibm_db to connect to the DB2/AS400.

The problem is that it returns the following error:

[SERVER] { Error: [IBM][CLI Driver] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968

[SERVER]

[SERVER]   errors: [],

[SERVER]   error: '[node-odbc] SQL_ERROR',

[SERVER]   message: '[IBM][CLI Driver] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968\r\n',

[SERVER]   state: '42968' }

there Is an alternative way to connect to AS400, from node, js that does not require a license?

This is the code we use for the connection:

"use strict";
var models = require("../../models/index");
var express = require("express");

var db2Route = express.Router();
const ibmdb = require("ibm_db");
//import ibm_db


const opts = [
    'DRIVER={IBM DB2 CLI DRIVER}',
    'DATABASE=*****',
    'PROTOCOL=TCPIP',
    'HOSTNAME=*****',
    'PORT=446',
    'UID=*****',
    'PWD=*****',
    'DBQ=,*USRLIBL'
];




db2Route.route("/").post((req, res) => {

    ibmdb.open(opts.join(';'), (err, conn) => {
        if (err) return console.log(err);

        conn.query("Select * from TBFR0F" ,(err, data) =>{
            if (err) console.log(err);
            else console.log(data);
            conn.close(() => console.log('done'));
        });
    });
});
Share Improve this question asked Apr 16, 2018 at 12:33 elcidelcid 312 silver badges9 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

If you have access (sorry I don't know how this is set up) you can use JDBC or ODBC. You can utilize the open source jt400 toolkit with Java (through Node.js) or you can use the node-jt400 package which wraps SOME OF the jt400 java library into node bindings.

const jt400 = require('node-jt400');
const { connect, pool, Connection, TransactionFun, BaseConnection } = jt400;
const jt400config = {
  host: 'POWER7',
  user: username,
  password: password,
  "translate binary": "true" // might be important for you...
};
const pool2 = await connect(jt400config);
const query = (pool,query) => new Promise((res, rej) => {
  pool
    .query(query)
    .then((results) => res(results))
    .catch((err) => rej(err));
});
let queryResults = await query(pool2,`
  SELECT * FROM (
    SELECT 
      asdf,
      asdf2,
      CONCAT(CONCAT(asdf3,asdf4),asdf5) AS asdf6
    FROM ${library}.${table}
  ) as A 
  WHERE asdf6= '${myAsfd6}'
`);

The ibm_db package uses Db2 Connect drivers under the covers. When connecting to IBM i, Db2 Connect requires a license as you have found.

Instead of using ibm_db, the remended way to connect from node is with node-odbc and the IBM i Access ODBC driver. This requires no license and works across Windows, Linux, and on IBM i in PASE. We have built our LoopBack and Sequelize support on top of this package.

Does this article from Aaron Bartell (who is v expert on the node.js / IBM i bo) help?

https://www.mcpressonline./analytics-cognitive/db2/techtip-node-js-on-linux-with-jdbc-connection-to-db2-for-i

He gives several options though none simply provides an alternative, free of charge, driver. He provides a worked example for his jdbc option.

we have a project with Node.js that use the ibm_db to connect to the DB2/AS400.

The problem is that it returns the following error:

[SERVER] { Error: [IBM][CLI Driver] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968

[SERVER]

[SERVER]   errors: [],

[SERVER]   error: '[node-odbc] SQL_ERROR',

[SERVER]   message: '[IBM][CLI Driver] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968\r\n',

[SERVER]   state: '42968' }

there Is an alternative way to connect to AS400, from node, js that does not require a license?

This is the code we use for the connection:

"use strict";
var models = require("../../models/index");
var express = require("express");

var db2Route = express.Router();
const ibmdb = require("ibm_db");
//import ibm_db


const opts = [
    'DRIVER={IBM DB2 CLI DRIVER}',
    'DATABASE=*****',
    'PROTOCOL=TCPIP',
    'HOSTNAME=*****',
    'PORT=446',
    'UID=*****',
    'PWD=*****',
    'DBQ=,*USRLIBL'
];




db2Route.route("/").post((req, res) => {

    ibmdb.open(opts.join(';'), (err, conn) => {
        if (err) return console.log(err);

        conn.query("Select * from TBFR0F" ,(err, data) =>{
            if (err) console.log(err);
            else console.log(data);
            conn.close(() => console.log('done'));
        });
    });
});

we have a project with Node.js that use the ibm_db to connect to the DB2/AS400.

The problem is that it returns the following error:

[SERVER] { Error: [IBM][CLI Driver] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968

[SERVER]

[SERVER]   errors: [],

[SERVER]   error: '[node-odbc] SQL_ERROR',

[SERVER]   message: '[IBM][CLI Driver] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968\r\n',

[SERVER]   state: '42968' }

there Is an alternative way to connect to AS400, from node, js that does not require a license?

This is the code we use for the connection:

"use strict";
var models = require("../../models/index");
var express = require("express");

var db2Route = express.Router();
const ibmdb = require("ibm_db");
//import ibm_db


const opts = [
    'DRIVER={IBM DB2 CLI DRIVER}',
    'DATABASE=*****',
    'PROTOCOL=TCPIP',
    'HOSTNAME=*****',
    'PORT=446',
    'UID=*****',
    'PWD=*****',
    'DBQ=,*USRLIBL'
];




db2Route.route("/").post((req, res) => {

    ibmdb.open(opts.join(';'), (err, conn) => {
        if (err) return console.log(err);

        conn.query("Select * from TBFR0F" ,(err, data) =>{
            if (err) console.log(err);
            else console.log(data);
            conn.close(() => console.log('done'));
        });
    });
});
Share Improve this question asked Apr 16, 2018 at 12:33 elcidelcid 312 silver badges9 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

If you have access (sorry I don't know how this is set up) you can use JDBC or ODBC. You can utilize the open source jt400 toolkit with Java (through Node.js) or you can use the node-jt400 package which wraps SOME OF the jt400 java library into node bindings.

const jt400 = require('node-jt400');
const { connect, pool, Connection, TransactionFun, BaseConnection } = jt400;
const jt400config = {
  host: 'POWER7',
  user: username,
  password: password,
  "translate binary": "true" // might be important for you...
};
const pool2 = await connect(jt400config);
const query = (pool,query) => new Promise((res, rej) => {
  pool
    .query(query)
    .then((results) => res(results))
    .catch((err) => rej(err));
});
let queryResults = await query(pool2,`
  SELECT * FROM (
    SELECT 
      asdf,
      asdf2,
      CONCAT(CONCAT(asdf3,asdf4),asdf5) AS asdf6
    FROM ${library}.${table}
  ) as A 
  WHERE asdf6= '${myAsfd6}'
`);

The ibm_db package uses Db2 Connect drivers under the covers. When connecting to IBM i, Db2 Connect requires a license as you have found.

Instead of using ibm_db, the remended way to connect from node is with node-odbc and the IBM i Access ODBC driver. This requires no license and works across Windows, Linux, and on IBM i in PASE. We have built our LoopBack and Sequelize support on top of this package.

Does this article from Aaron Bartell (who is v expert on the node.js / IBM i bo) help?

https://www.mcpressonline./analytics-cognitive/db2/techtip-node-js-on-linux-with-jdbc-connection-to-db2-for-i

He gives several options though none simply provides an alternative, free of charge, driver. He provides a worked example for his jdbc option.

本文标签: javascriptNodejs with db2AS400Stack Overflow