ToolJet/ToolJet · error · QueryError
Connection test failed
Error message
Connection test failed
What it means
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.
Source
Thrown at plugins/packages/ibmdb/lib/index.ts:41
return { status: 'ok', data: rows };
} catch (err: any) {
throw new QueryError('Query could not be completed', err.message || 'An unknown error occurred', {
sqlcode: err.sqlcode ?? null,
state: err.state ?? null,
});
} finally {
if (conn) await this.safeClose(conn);
}
}
async testConnection(sourceOptions: SourceOptions): Promise<ConnectionTestResult> {
let conn: any;
try {
conn = await this.openConnection(sourceOptions);
await this.executeQuery(conn, 'SELECT 1 FROM SYSIBM.SYSDUMMY1');
return { status: 'ok' };
} catch (err: any) {
throw new QueryError('Connection test failed', err.message || 'An unknown error occurred', {
sqlcode: err.sqlcode ?? null,
state: err.state ?? null,
});
} finally {
if (conn) await this.safeClose(conn);
}
}
private buildConnectionString(sourceOptions: SourceOptions): string {
const { host, port, database, username, password } = sourceOptions;
const parts: string[] = [
`HOSTNAME=${host}`,
`PORT=${port || 50000}`,
`PROTOCOL=TCPIP`,
`UID=${username}`,
`PWD=${password || ''}`,
];
// DATABASE is optional — DB2 z/OS does not require it; DB2 LUW typically doesView on GitHub (pinned to 20602a8e10)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
for (const k of ['host','port','database','username','password']) {
if (!sourceOptions[k]) throw new Error(`${k} is required`);
}
if (!/^[1-9][0-9]{0,4}$/.test(String(sourceOptions.port))) throw new Error('invalid port'); Type guard
function isQueryError(e): e is QueryError { return e?.name === 'QueryError' || /Connection test failed/.test(e?.message ?? ''); } Try / catch
try { result = await plugin.testConnection(sourceOptions); }
catch (e) {
if (isQueryError(e)) showFormError(`DB2: sqlcode ${e.data?.sqlcode} - ${e.message}`);
throw e;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Connection could not be established
- Connection could not be established
- No query selected
- No application slug provided
- No application selected
AI-assisted analysis of ToolJet/ToolJet@20602a8e10 (2026-08-13).
Data as JSON: /api/errors/3584926e98b2054d.
Report an issue: GitHub.