To compile a DB2 LUW program, you must first connect to a database. The database itself is specified by the DB2 ECM directive, DB. User credentials are also provided to the compiler by the DB2 ECM preprocessor. The login credentials used to connect to the database can vary depending on whether the database is local or remote, what DB2 compiler directive options have been specified, and what environment variables have been set.
The DB2 ECM checks for login credentials in one or more places and in a particular sequence, and attempts to connect using the credentials provided in each place until the connection succeeds.
When you specify login credentials using PASS, they take precedence over credentials supplied by any other means. If the connection succeeds using the credentials provided, then compilation proceeds. PASS is required to connect to a remote DB2 database. If the connection fails using the credentials provided by PASS, the DB2 ECM next looks for the SQLPASS.TXT environment variable.
If you have not specified login credentials using the PASS compiler directive option, or if this approach yields unusable credentials, the DB2 ECM attempts to make the connection using your current Operating System credentials. This compilation attempt can succeed only if you are using a local database.
If you are using a remote database, or if the connection to a local database fails using your Operating System credentials, use the PASS compiler directive option. Be sure to provide usable credential specifications.