MainframeKit

-922

SQLSTATE 42505NEGATIVE SQLCODE

Db2 refused the connection because an authorization check failed: the user ID, access to the plan, a sign-on exit, or a CONNECT with a user ID and password.

MOST LIKELY

User authorization: the ID passed by the TSO, CICS, IMS or batch attachment is not valid for Db2.

FIRST CHECK

Note the error type and reason code; look the reason code up in the Db2 codes documentation.

TRY IT ▸

MainframeKit assistant

What it means

The program could not connect to Db2 because authorization failed. The message gives an error type and a Db2 reason code. Error types are user authorization, plan access, duplicate exit requested, installation error and connect. The statement is not run and no connection is made. SQLSTATE is 42505.

Except for the connect type, do not issue more SQL after a -922; the results are unpredictable. After a connect failure, the program is left unconnected and only CONNECT, COMMIT, ROLLBACK and local SET statements work.

Typical causes

  • User authorization: the ID passed by the TSO, CICS, IMS or batch attachment is not valid for Db2.
  • Plan access: the ID has no EXECUTE on the plan, or the plan does not exist.
  • Installation error: a connection or sign-on exit rejected the request.
  • Connect: a CONNECT ... USER ... USING failed, for example a wrong password.
  • The job runs under a different user ID than the one the grants were made to.

How to fix it

  1. Note the error type and reason code; look the reason code up in the Db2 codes documentation.
  2. For plan access, check that the plan exists (SYSIBM.SYSPLAN) and that the ID has EXECUTE on it (SYSPLANAUTH).
  3. For user authorization or installation errors, give the details to the security or Db2 system programmer.
  4. For connect errors, check the user ID and password used in the CONNECT.
  5. Confirm which user ID the job or transaction actually ran under.

Example

Illustrative only; names and values are invented.

DSNT408I SQLCODE = -922, ERROR:  AUTHORIZATION FAILURE: PLAN ACCESS ERROR.
         REASON reason-code
DSNT418I SQLSTATE   = 42505 SQLSTATE RETURN CODE