pjs.connect()

This API can be used to connect to remote IBMi DB2 databases.

Parameter

  • Database (string) - The name of the remote database

  • Username (string, optional) - The user name for authenticating to remote database

  • Password (string, optional) - The password for authenticating to remote database

Example

exports.activationGroup = "*new"; function connect3() { pjs.define("remote_user", { type: "char", length: 10, varying: true, initValue: "**********" }); pjs.define("remote_pwd", { type: "char", length: 10, varying: true, initValue: "**********" }); pjs.define("colData", { type: "char", length: 20, varying: true }); pjs.define("msg", { type: "char", length: 50 }); pjs.define("c1", { type: "cursor" }); c1 = pjs.allocStmt(); pjs.setConnectAttr(SQL_TXN_ISOLATION, SQL_TXN_REPEATABLE_READ); pjs.setConnectAttr(SQL_ATTR_DBC_SYS_NAMING, SQL_FALSE); // Connect to remote DB "remote" pjs.connect("remote", remote_user, remote_pwd); c1.executeDirect("select col1 from library.db"); do { pjs.fetch(c1, colData); if (sqlcod !== 100) { msg = colData; console.log("" + " " + msg); } } while (sqlcod !== 100); if (c1) c1.close(); pjs.disconnect(); flags["LR"] = true; } exports.default = connect3;