node-ibm_db installation

Although Node.js needs no introduction allow me to give you a brief overview : Node.js is a JavaScript runtime powered by Chrome’s V8 JavaScript engine. Its signature event-driven, non-blocking I/O model makes it lightweight and efficient. With over a million npm packages currently available, Node.js is currently one of the most popular frameworks for backend development on the market.
Most of the things that you want to do in your Node.js application are probably covered by one of the million packages already available in the Node.js community. In our case, we want to connect to IBM Db2 with SDK for Node.js all within z/OS, and we have a npm package to do that: node-ibm_db.

Prerequisites

Install IBM SDK for Node.js – z/OS

To install Node.js on z/OS, you need IBM SDK for Node.js – z/OS ®, which is available for download here.
Follow the installation instructions on IBM Knowledge Center to install SDK for Node.js – z/OS.

Db2 and ODBC driver Setup

Before installing node-ibm_db module, you need to have Db2 or ODBC driver setup on your z/OS machine. Contact your system admin for Db2 and ODBC installation and follow ODBC Guide and References to configure your ODBC driver.
Please ensure the following:
  • During installation of Db2 on z/OS, apply PTF UI60551 to pick up new ODBC functionality to support Node.js application
  • Bind the ODBC package. A sample JCL is provided in the SDSNSAMP dataset in member DSNTIJCL. Customize the JCL with specifics of your system.
  • Ensure users that should be authorized have authority to execute the DSNACLI plan. Contact your system admin if you do not have authority to do so.
  • Set the IBM_DB_HOME environment variable to the High-Level Qualifier (HLQ) of your Db2 datasets. For example, if your Db2 datasets are located as DSNC10.SDSNC.H and DSNC10.SDSNMACS, you need to set IBM_DB_HOME environment variable to DSNC10 with the following statement (can be saved in ~/.profile):
# Set HLQ of Db2 datasets. 

export IBM_DB_HOME="DSNC10" 
  • Update the STEPLIB environment variable to include the Db2 SDSNEXIT, SDSNLOAD and SDSNLOD2 data sets. You can set the STEPLIB environment variable with the following statement, after defining IBM_DB_HOME to the HLQ of your Db2 datasets as instructed above:
# Assumes IBM_DB_HOME specifies the HLQ of the Db2 datasets. 

export STEPLIB=$STEPLIB:$IBM_DB_HOME.SDSNEXIT:$IBM_DB_HOME.SDSNLOAD:$IBM_DB_HOME.SDSNLOD2 
  • Configure an appropriate Db2 ODBC initialization file that can be read at application time. You can specify the file by using either a DSNAOINI data definition statement or by defining a DSNAOINI z/OS UNIX environment variable. For compatibility with node-ibm_db and node.js, the following properties MUST BE SET:
In COMMON section:
MULTICONTEXT=2 

CURRENTAPPENSCH=ASCII 

FLOAT=IEEE 
In SUBSYSTEM section:
MVSATTACHTYPE=RRSAF 
For example, we saved the following complete initialization file to ~/odbc.ini
; This is a comment line... 

; Example COMMON stanza 

[COMMON] 

MVSDEFAULTSSID=VC1A 

CONNECTTYPE=1 

MULTICONTEXT=2 

CURRENTAPPENSCH=ASCII 

FLOAT=IEEE 

; Example SUBSYSTEM stanza for VC1A subsystem 

[VC1A] 

MVSATTACHTYPE=RRSAF 

PLANNAME=DSNACLI 

; Example DATA SOURCE stanza for STLEC1 data source 

[STLEC1] 

AUTOCOMMIT=1 

CURSORHOLD=1 
You can then set DSNAOINI
export DSNAOINI=[YOUR_PATH]/odbc.ini 
If you want to see the ODBC trace for debugging purposes, you can do so by specifying the following under COMMON section
APPLTRACE=1 

; specify a path you want to save your trace in 

APPLTRACEFILENAME="~/trace.log" 
Reference Chapter 3 in the ODBC Guide and References for more instructions.

node-ibm_db installation

You can install node-ibm_db in your node application either with npm that shipped with IBM SDK for Node.js – z/OS or from the GitHub repository (requires Git on z/OS):
# Install via npm repository 

npm install ibm_db 



# --- OR ----- 



# Install from GitHub repository 

npm install git+ssh://git@github.com/ibmdb/node-ibm_db.git  
You can import the module in your application by:
const ibmdb = require(‘ibm_db’); 
Or you can manually install by using git clone (requires Git on z/OS):
git clone git://github.com/ibmdb/node-ibm_db 

cd node-ibm_db 



# Install the module dependencies 

npm install 
However, using this method will require you to include node-ibm_db into your source control as it will not register in your package.json and thus your node modules. When importing node-ibm_db, point to the directory instead:
const ibmdb = require(‘[YOUR_PATH_TO_IBMDB_DIR]’); 
Now you have installed node-ibm_db and are ready to connect to your Db2 system in z/OS.



Comments

Popular posts from this blog

The Complete Guide to Vue.js User Authentication with Auth0

Kubernetes Locally using - minikube, microk8s, k3s, k3d, k0s, kind, crc, minishift, firekube

Azure Pipelines vs. GitHub Actions