Info |
---|
Support for ODBC was added in Profound.js 5.3.0. |
...
The "odbc" driver does not allow non-SQL APIs (such as for direct program/procedure call, CL command, etc.) to run against the target system.
Limitations
- The current version of the IBM i Access ODBC driver does not support calls to stored procedures with CLOB parameters.
- Installation of the odbc package is not as simple as most NPM packages. The package has to be built from source code at installation time – see below.
Installation
The "odbc" driver utilizes 3 different components that need to be installed on the 'source' system only. Meaning, the system where you are running Profound.js and want to connect to IBM i.
- The Profound.js "odbc" driver. This component is built into Profound.js, starting with version 5.3.0 and relies on the following components for connectivity to the target system.
- The open source package odbc, which must be installed separately via NPM. This package provides a Node.js interface for using ODBC drivers.
- The ODBC driver for the target system. This package performs the actual work of communicating with the target database. For example, ODBC access to IBM i is provided by the IBM i Access ODBC Driver, which is supplied by IBM.
Installing the odbc Package with NPM
See the package's installation instructions on NPM, here:
...
If you get an error attempting to install the package, ensure that these tools are installed/configured properly on your system.
Installing the IBM i Access ODBC Driver
The ODBC driver is provided as part of the IBM i Access Client Solutions Application Package. The Application Package is a separate installation from the main ACS installation that includes the TN5250 emulator. Versions are available for Windows, Linux, Mac, and IBM i. To download the Application Package, visit the IBM i ACS Home Page here:
...
An IBM account is required to access the downloads. Click on Downloads for IBM i Access Client Solutions, accept the license agreement, and use the ACS App Pkg link for the appropriate source operating system. For IBM i, use ACS PASE App Pkg. Installation instructions are included in each download package.
The IBM i version of the Application package installs via the open-source package manager "yum". See here for instructions on setting up yum on IBM i:
https://www.ibm.com/support/pages/node/706903
For Application Package installers for 32-bit Windows or languages other than English, visit the IBM ESS Website.
Configuration
Connections are configured using the databaseConnections property in the Profound.js configuration file. For example:
...
Option | Required Value |
---|---|
nam | 1 |
unicodesql | 1 |
tsft | 1 |
Creating a Credentials File
The example configuration above uses an encrypted credentials file. To create a credentials file, run the following command from your Profound.js installation directory and enter the desired user id and password when prompted:
...
When using this option, specify the "connectionString" without the "uid" and "pwd" options.
Using ODBC Data Sources (optional)
An ODBC Data Source is an alternative way of specifying ODBC connection options. A Data Source is an OS-dependent location (such as a file) where ODBC connection options are stored. When using a Data Source, you can simply specify the Data Source Name (DSN) in the "connectionString", and the options are loaded from the Data Source. Connection options can also be specified on the "connectionString" along with the DSN. In this case, the options override those from the Data Source.
The process of creating a Data Source depends on the source operating system.
Creating a Data Source on Linux, Mac, and IBM i
On these systems, Data Sources are stored in a text file named "odbc.ini". The file location depends on the OS, but is typically /etc/odbc.ini. On IBM i, the location is /QOpenSys/etc/odbc.ini. The file can be edited directly, but it's recommended to use the odbcinst command-line utility to add/remove data sources. On IBM i, the odbcinst command can be run in a PASE shell.
...
Code Block |
---|
odbcinst -u -s -l -n DATA_SOURCE_NAME |
Creating a Data Source on Windows
On Windows, ODBC Data Sources are stored in files in a directory of your choosing. To find the directory currently configured as the location for Data Source files on your system, launch the ODBC Data Sources application by typing 'odbc data sources' into the Windows search box, and choosing the correct version for your Windows installation (usually 64-bit):
...
To remove or change a DSN, simply edit or delete the file.
Optimizing ODBC Pool Performance
When the odbc package has to create several pool connections at once (such as when establishing the initial set of pool connections), queries can get held up until all the connections are completed. Establishing each connection can take some time, especially when connecting to IBM i over a WAN. This can result in a long delay running a query while connections are being established. To mitigate this, Profound.js begins the process of establishing the connection pool immediately as the server is starting up. However, delays can occur if the connection pool is configured such that it can grow by large increments. See the pool configuration options here:
...
Code Block |
---|
"driverOptions": { "connectionString": "DSN=myIBMi;", "initialSize": 10, "maxSize": 20, "incrementSize": 2 "shrink": false } |
Tuning IBM i Server Jobs
Each ODBC connection attaches to its own server job named QZDASOINIT, which runs in the QUSRWRK sub-system. The sub-system is configured to prestart some QZDASOINIT jobs so that jobs are available before connections are established. However, the default sub-system configuration only creates 1 pre-start job, which is usually not realistic. This can cause delays in establishing ODBC connections if the system has to start many jobs at once as connections are made. See here for an explanation of how to change the prestart job configuration:
...
The number of pre-start jobs should be configured based on the ODBC connection pool size used.
Security
If connecting to IBM i from outside the private network or VPN, it's recommended to use the option SSL=1 on the "connectionString" or DSN configuration to enable encrypted communications. This option requires that various IBM i services are configured for SSL, using a certificate that is trusted by the source system.
...