Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

idb-connector

Package Overview
Dependencies
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

idb-connector

A Node.js DB2 driver for IBM i

  • 1.0.11
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
160
decreased by-21.57%
Maintainers
3
Weekly downloads
 
Created
Source

Node.js iDB Connector

The Node.js iDB Connector is a Node.js DB2 driver open source project from IBM.

Installation

npm -g i idb-connector

Then you can require('idb-connector') in your code.

If you encounter below error messega:

Error: Cannot find module 'idb-connector'  

you need to add the idb-connector path:

export NODE_PATH=/QOpenSys/pkgs/lib/nodejs8/lib/node_modules

Quick Example

Example 1: Fectching data using the exec() API

	var db = require('idb-connector');
	var sSql = 'SELECT STATE FROM QIWS.QCUSTCDT';
	var dbconn = new db.dbconn();
	dbconn.conn("*LOCAL");
	var stmt = new db.dbstmt(dbconn);

	stmt.exec(sSql, (x) => {
	  console.log("%s", JSON.stringify(x));
	  stmt.close();
	  dbconn.disconn();
	  dbconn.close();
	});

Example 2: Fectching data using the fetchAll() API

	var db = require('idb-connector');
	var sSql = 'SELECT STATE FROM QIWS.QCUSTCDT';
	var dbconn = new db.dbconn();
	dbconn.conn("*LOCAL");
	var stmt = new db.dbstmt(dbconn);

	stmt.prepare(sSql, () => {
	  stmt.executeSync(() => {
		stmt.fetchAll((x) => { 
		  console.log("%s", JSON.stringify(x));
		  stmt.close();
		});
	  });
	});

Example 3: Call stored procedures

    var db = require('idb-connector');
    var sql = "call QXMLSERV.iPLUG512K(?,?,?,?)";
    var dbconn = new db.dbconn();
    dbconn.conn("*LOCAL");
    var stmt = new db.dbstmt(dbconn);

    var ipc = "*NA";
    var ctl = "*here";
    var xmlIn = "<xmlservice><sh>system 'wrksbs'</sh></xmlservice>";
    var xmlOut;

    stmt.prepare(sql, () => {
      stmt.bindParam([
        [ipc, db.SQL_PARAM_INPUT, 1], // 1 -- null-terminated string
        [ctl, db.SQL_PARAM_INPUT, 1],
        [xmlIn, db.SQL_PARAM_INPUT, 0], // 0 -- CLOB string
        [xmlOut, db.SQL_PARAM_OUTPUT, 0],
      ], function(){
        stmt.execute((out) => { // 'out' is an array of output params
          for(var i = 0; i < out.length; i++)
            console.log(out[i]);
          stmt.close();
          dbconn.disconn();
          dbconn.close();
        });
      });
    });

API Reference

https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/DB2%20for%20i%20Access%20APIs%20-%20New

License

MIT. View LICENSE file.

Keywords

FAQs

Package last updated on 22 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc