ibm_db is a native Node.js driver providing both asynchronous (Promise-based and async/await compatible) and synchronous interfaces for connecting to IBM DB2 and IBM Informix databases. The current stable version is 4.0.0. Releases are relatively frequent, addressing dependencies, platform support, and core driver updates. A key differentiator is its native C++ binding, offering direct high-performance access to IBM databases, and its automatic download of the necessary `clidriver`. It supports a wide array of platforms including Windows, macOS (Intel & ARM), Linux (x64, IBM Z, Power PC), and AIX, making it suitable for diverse enterprise environments. Since v4.0.0, it utilizes Node-API (N-API) for improved version independence.
npm install ibm_dbVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to establish a connection to a DB2 database, create a table (handling existing tables), insert data, query data, and update data using the asynchronous API, ensuring the connection is properly closed.
No direct code changes are typically required for standard usage, as N-API ensures ABI stability across Node.js versions. However, if you have custom native modules that interact with `ibm_db`'s internals, they might need to be re-evaluated or updated to use N-API.
If you have an older `db2connect` license, install `ibm_db` by explicitly specifying the older `clidriver` version: `npm install ibm_db --clidriver="v11.5.9"`. Otherwise, acquire a compatible v12.1 db2connect license.
Refer to the `ibm_db` APIDocumentation on GitHub specifically for 'SSLConnection' instructions. Ensure proper `DB2CLNTOPT` environment variables or connection string parameters are set, and certificates are correctly configured and accessible.
Ensure `gcc` (version >= 8.4), `g++` (gcc-c++), `python3` (>=3.8.0), and `make` are installed. On RHEL, update your compiler. On Docker, include `RUN apt-get update && apt-get install gcc g++ libcrypt libxcrypt-compat python3 make -y` in your Dockerfile. For WSL, install `build-essentials`.
Install `ibm_db` using the `--unsafe-perm` flag: `npm install --unsafe-perm ibm_db`. This allows `node-gyp` to run scripts with root privileges if necessary.
Verify that your `db2connect` license is valid and compatible with the `clidriver` version downloaded by `ibm_db`. If using `ibm_db@3.3.0` or newer, ensure you have a v12.1 db2connect license or explicitly install with an older clidriver (`npm install ibm_db --clidriver="v11.5.9"`).
Consult the `ibm_db` API Documentation for 'SSLConnection' to correctly configure SSL. Ensure all necessary certificates are in place, accessible, and specified correctly in your connection string or environment variables (e.g., `DB2CLNTOPT`).
Ensure `make`, a C++ compiler (like `gcc`/`g++` version >= 8.4), and `python3` (>=3.8.0) are installed and accessible in your system's PATH. On Windows, ensure Visual Studio (2015.3 v14.00 or >= 2022) is installed if precompiled binaries are not used.
Check prerequisites: ensure C++ compiler (C++11 support), Python3 (>=3.8.0), and `make` are installed. For Docker, use `npm install --unsafe-perm ibm_db` for root users and ensure build dependencies are installed (`RUN apt-get update && apt-get install gcc g++ python3 make -y`). Since v4.0.0 uses N-API, Node.js version compatibility should be less of an issue, but build tools are still required if precompiled binaries are not applicable.
No dependency data recorded yet.