From YiPs Wiki (i powered)

NodeJs: Node Js

Yep, you heard correct, IBM i supports node.js via PTF.

API documentation

New db2a asynchronous APIs

The db2a designers were very good users creating two different types of APIs. All asynchronous related APIs have counterpart synchronous versions like db.prepare (asynchronous) and db.prepareSync (synchronous).

Synchronous APIs: execSync, prepareSync, executeSync, fetchSync, etc.

If you are uncomfortable with asynchronous callback programming, or you find your application is behaving erratically, please consider using ‘Sync’ versions of db2a APIs.

Asynchronous APIs: exec, prepare, execute, fetch, etc.

You MUST use a DB2 connection pool to effectively use db2a APIs. Basically, rule of effective DB2 is never share a resource (connection, statement), across threads. Yes, technically nodejs interpreter NOT threaded. However, asynchronous APIs are implemented by using child threads. That is, prepare, execute, etc., are placed in a worker thread while doing DB2 operation (I/O), then return to the event loop on completion (callback). Therefore, threads are used, and, the DB2 ‘no share resource across threads’ rules must be followed. There is a sample connection pool with the bears example below.

nodejs toolkit

The nodejs tool kit has multiple transports:

Some better examples

IBM i examples running on Yips use following conf files

Follow links for extended conversation about setting up a ‘safer’ Apache, xmlservice with *NONE uid/pwd, mama, etc. A new tool ‘mama’ has been created as fastcgi extension to start/stop your standalone applications. Mama is designed to work with Apache FastCGI as additional configuration files (mama.conf).

IBM i db2a bears example for new db2a ‘async’ interfaces (ported to node 6) …

IBM i toolkit flight 400 interfaces node 6 (yes, calling flight 400 RPG programs).

IBM i toolkit silly hat example (ported to node 6) …

IBM i hats.savf

Original bluemix silly hat example (bluemix obsolete)…

Our friends at Litmis/Krengel made a bitbucket repository for Node.js on IBM i …

CCSID issues

Have CCSID issues? Junk characters? Nothing works?

Retrieved from
Page last modified on March 21, 2019, at 04:39 PM EST