DRDA Connectivity Test — Exit codes
On success the tool prints the resolved server name and the query result to standard output. On failure it prints a single-line diagnostic to standard error — never containing credentials — and returns the matching code below. These codes are stable and form the tool's contract.
The contract
| Code | Meaning |
|---|---|
| 0 | Success — connected and the sanity query returned a row |
| 1 | Usage error (wrong number of arguments) |
| 2 | INFORMIXDIR required but not set, and no INFORMIXSQLHOSTS |
| 3 | sqlhosts file not found or unreadable |
| 4 | Server name not found in sqlhosts |
| 5 | Unsupported protocol or entry type — not drsoctcp/drsocssl, or a group entry |
| 6 | Service/port resolution failed |
| 7 | Missing or invalid SSL trust material for a drsocssl server |
| 8 | Connection failed — host unreachable, timeout, or listener down |
| 9 | Authentication failed |
| 10 | Query execution failed |
Distinguishing 8 from 9
This is the distinction that matters most in a connectivity tool, and the one that is easiest to get wrong. DRDA reports both “could not reach the server” and “reached the server and was refused” under SQLSTATE 08001. SQLSTATE alone therefore cannot separate them; the native error code must be used.
| Native | Message | Meaning | Code |
|---|---|---|---|
| -30081 | SQL30081N | Communication error — listener down, port closed, host unreachable, timeout | 8 |
| -30082 | SQL30082N | Security processing failed — the DRDA conversation reached authentication | 9 |
A -30082 therefore implies connectivity succeeded: the transport, the DRDA handshake and the server's security layer were all reached. Reporting it as code 8 would invert the very result the tool exists to measure. SQLSTATE class 28 is also treated as code 9, for drivers that report authentication that way.
Observed against a live listener, all three of the following return SQLSTATE 08001 and are separated only by the native code:
| Case | Native | Exit |
|---|---|---|
| Closed port | SQL30081N | 8 |
| Unroutable host | SQL30081N | 8 |
| Live listener, bad credentials | SQL30082N | 9 |
Reading SQL30082N reason codes
Code 9 covers more than a mistyped password. The reason code carried in the SQL30082N text says which:
| Reason | Text | Interpretation |
|---|---|---|
| 24 | USERNAME AND/OR PASSWORD INVALID | The mechanism was accepted; the credentials were wrong. |
| 17 | UNSUPPORTED FUNCTION | The mechanism itself was refused — typically a credential-less or user-id-only attempt against a listener that requires user-id plus password. |
Both return exit 9, since both are authentication-layer refusals that prove connectivity. The stderr line carries the reason text, so the distinction is visible without changing the exit code.
The one code outside the contract
A host missing the IBM CLI driver fails in the dynamic loader before the program starts:
drdatest: error while loading shared libraries: libdb2.so.1: cannot open shared object file: No such file or directory
That exits 127 — the shell's “command cannot execute” — not any code from the table above. Nothing inside the tool can trap it, because main() never runs. If a script sees 127, the problem is deployment, not connectivity.