{"record":{"id":"3584926e98b2054d","repo":"ToolJet/ToolJet","slug":"connection-test-failed-358492","errorCode":null,"errorMessage":"Connection test failed","messagePattern":"Connection test failed","errorType":"exception","errorClass":"QueryError","httpStatus":null,"severity":"error","filePath":"plugins/packages/ibmdb/lib/index.ts","lineNumber":41,"sourceCode":"      return { status: 'ok', data: rows };\n    } catch (err: any) {\n      throw new QueryError('Query could not be completed', err.message || 'An unknown error occurred', {\n        sqlcode: err.sqlcode ?? null,\n        state: err.state ?? null,\n      });\n    } finally {\n      if (conn) await this.safeClose(conn);\n    }\n  }\n\n  async testConnection(sourceOptions: SourceOptions): Promise<ConnectionTestResult> {\n    let conn: any;\n    try {\n      conn = await this.openConnection(sourceOptions);\n      await this.executeQuery(conn, 'SELECT 1 FROM SYSIBM.SYSDUMMY1');\n      return { status: 'ok' };\n    } catch (err: any) {\n      throw new QueryError('Connection test failed', err.message || 'An unknown error occurred', {\n        sqlcode: err.sqlcode ?? null,\n        state: err.state ?? null,\n      });\n    } finally {\n      if (conn) await this.safeClose(conn);\n    }\n  }\n\n  private buildConnectionString(sourceOptions: SourceOptions): string {\n    const { host, port, database, username, password } = sourceOptions;\n    const parts: string[] = [\n      `HOSTNAME=${host}`,\n      `PORT=${port || 50000}`,\n      `PROTOCOL=TCPIP`,\n      `UID=${username}`,\n      `PWD=${password || ''}`,\n    ];\n    // DATABASE is optional — DB2 z/OS does not require it; DB2 LUW typically does","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/ToolJet/ToolJet/blob/20602a8e101f2e59686c9afde0d1402aac2c8871/plugins/packages/ibmdb/lib/index.ts#L23-L59","documentation":"Catch-all in ibmdb testConnection: wraps any failure during openConnection or the `SELECT 1 FROM SYSIBM.SYSDUMMY1` probe as a QueryError titled 'Connection test failed', forwarding err.message plus sqlcode/state. Used by the datasource 'Test Connection' button.","triggerScenarios":"Wrong host/port/database/credentials in buildConnectionString, IBM i Db2 not reachable, user lacks CONNECT authority, or the driver failed to load/bind (idb-connector native module issue).","commonSituations":"Typo in host or database name, wrong credentials, firewall between the tool and Db2, or the odbc/idb-connector PASE library missing on the host.","solutions":["Verify host, port, database, username, password in sourceOptions.","Check the forwarded err.message / sqlcode for the DB2 reason code (e.g. SQL30081N for transport).","Confirm network reachability from the tool host to the Db2 port.","Ensure the driver native dependencies are installed for the runtime platform."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for (const k of ['host','port','database','username','password']) {\n  if (!sourceOptions[k]) throw new Error(`${k} is required`);\n}\nif (!/^[1-9][0-9]{0,4}$/.test(String(sourceOptions.port))) throw new Error('invalid port');","typeGuard":"function isQueryError(e): e is QueryError { return e?.name === 'QueryError' || /Connection test failed/.test(e?.message ?? ''); }","tryCatchPattern":"try { result = await plugin.testConnection(sourceOptions); }\ncatch (e) {\n  if (isQueryError(e)) showFormError(`DB2: sqlcode ${e.data?.sqlcode} - ${e.message}`);\n  throw e;\n}","preventionTips":["Make all connection fields required in the form schema.","Surface e.data.sqlcode in the UI (e.g. SQL30081N = transport issue).","Confirm the idb-connector/odbc native module loads for the runtime platform."],"tags":["ibmdb","connection","configuration"],"backgroundTag":null,"analyzedSha":"20602a8e101f2e59686c9afde0d1402aac2c8871","analyzedAt":"2026-08-13T05:58:54.221Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}