Overview
This node executes SQL queries on an IBM DB2 database using one of several connection methods: REST API, JDBC, or ODBC. It supports parameterized queries and allows configuration of query execution options such as timeout and maximum rows returned.
Common scenarios for this node include:
- Running custom SQL queries against IBM DB2 databases to retrieve or manipulate data.
- Integrating IBM DB2 data into workflows for reporting, data transformation, or automation.
- Using prepared statements with parameters to safely execute dynamic queries.
- Connecting via different protocols depending on environment constraints (REST, JDBC, or ODBC).
Practical example:
- A user wants to fetch customer records where the status is 'active'. They write a parameterized SQL query like
SELECT * FROM CUSTOMERS WHERE STATUS = :statusand provide the parameterstatus=active. The node executes the query and returns matching rows.
Properties
| Name | Meaning |
|---|---|
| Query | The SQL query to execute on the IBM DB2 database. Supports multi-line input with SQL editor. |
| Query Parameters | List of named parameters for prepared statements. Each parameter has a name and a value. |
| Options | Additional execution options: • Timeout (seconds): Request timeout duration. • Max Rows: Maximum number of rows to return from the query. |
Output
The node outputs an array of JSON objects representing the rows returned by the executed SQL query. Each object corresponds to a single row, with keys as column names and values as the respective cell values.
If no rows are returned, the output will be an empty array.
The node does not output binary data.
Dependencies
- Requires an IBM DB2 database accessible via one of these connection types:
- REST API endpoint with proper authentication.
- JDBC connection with the IBM DB2 JDBC driver (
db2jcc4.jar) installed and configured. - ODBC connection with the
ibm_dbNode.js package installed.
- For ODBC connections, the
ibm_dbpackage must be installed locally (npm install ibm_db). This requires build tools like make, gcc, and python. - For JDBC connections, the
jdbcNode.js package must be installed (npm install jdbc) and the DB2 JDBC driver JAR file must be available. - Credentials must include necessary connection details and authentication tokens or passwords.
- Optional SSL configuration can be provided for secure connections.
Troubleshooting
- Missing packages: If using ODBC or JDBC connection types, ensure the required Node.js packages (
ibm_dborjdbc) are installed. Errors will prompt installation instructions. - Connection timeouts: Connection or query timeouts can occur if the database is unreachable or slow. Adjust the "Timeout (seconds)" option accordingly.
- Query errors: Syntax errors or invalid parameters in the SQL query will cause execution failures. Verify the query syntax and parameter names.
- REST API connection issues: If using REST connection type, verify that DB2 REST services are enabled and accessible at the specified host, port, and path. Check credentials have REST API access.
- Max Rows limit: If the result set exceeds the "Max Rows" option, only the first N rows are returned.
- Character encoding issues: The node attempts to fix common character encoding problems in ODBC results, but some characters might still appear incorrectly if the database uses unusual encodings.