The loopback-connector-db2z connector enables LoopBack applications to connect to IBM® DB2® for z/OS® data sources.Note: This page was generated from the loopback-connector-db2z/README.md.

loopback-connector-db2z

IBM® DB2® for z/OS® is the database of choice for robust, enterprise-wide solutions handling high-volume workloads.It is optimized to deliver industry-leading performance while lowering costs. The loopback-connector-db2zmodule is the LoopBack connector for DB2z.

The LoopBack DB2z connector supports:

Installation

Enter the following in the top-level directory of your LoopBack application:

  1. $ npm install loopback-connector-db2z --save

The —save option adds the dependency to the application’s package.json file.

This module is dependent on the node-ibm_db module which requires appropriate licenses be available as per instructions in its README. Once loopback-connector-db2z is installed please copy the required license file to the location described.

Configuration

Use the data source generator to add the DB2z data source to your application.The resulting entry in the application’s server/datasources.json will look something like this:

  1. "mydb": {
  2. "name": "mydb",
  3. "connector": "db2z"
  4. }

Edit server/datasources.json to add other supported properties as required:

  1. "mydb": {
  2. "name": "mydb",
  3. "connector": "db2z",
  4. "username": <username>,
  5. "password": <password>,
  6. "database": <database name>,
  7. "hostname": <db2z server hostname>,
  8. "port": <port number>
  9. }

The following table describes the connector properties.

Property Type Description
databaseStringDatabase name
schemaStringSpecifies the default schema name that is used to qualify unqualified database objects in dynamically prepared SQL statements. The value of this property sets the value in the CURRENT SCHEMA special register on the database server. The schema name is case-sensitive, and must be specified in uppercase characters
usernameStringDB2z Username
passwordStringDB2z password associated with the username above
hostnameStringDB2z server hostname or IP address
portStringDB2z server TCP port number
useLimitOffsetBooleanLIMIT and OFFSET must be configured on the DB2z server before use (compatibility mode)
supportDashDBBooleanCreate ROW ORGANIZED tables to support dashDB.

Alternatively, you can create and configure the data source in JavaScript code.For example:

  1. var DataSource = require('loopback-datasource-juggler').DataSource;
  2. var DB2Z = require('loopback-connector-db2z');
  3. var config = {
  4. username: process.env.DB2Z_USERNAME,
  5. password: process.env.DB2Z_PASSWORD,
  6. hostname: process.env.DB2Z_HOSTNAME,
  7. port: 50000,
  8. database: 'SQLDB',
  9. };
  10. var db = new DataSource(DB2Z, config);
  11. var User = db.define('User', {
  12. name: { type: String },
  13. email: { type: String },
  14. });
  15. db.autoupdate('User', function(err) {
  16. if (err) {
  17. console.log(err);
  18. return;
  19. }
  20. User.create({
  21. name: 'Tony',
  22. email: 'tony@t.com',
  23. }, function(err, user) {
  24. console.log(err, user);
  25. });
  26. User.find({ where: { name: 'Tony' }}, function(err, users) {
  27. console.log(err, users);
  28. });
  29. User.destroyAll(function() {
  30. console.log('example complete');
  31. });
  32. });

Tags: connectorsreadme