Troubleshooting: Database connection errors when utilities run from a command-line interface

If certain characters are used in a DB2 password, they can cause errors when the password is specified on a command-line interface when you run a utility.

Note: You can also encounter errors when you are running a process or utility if the input parameters that are used to establish a database connection are incorrect. To validate that a database connection can be established with the configured input parameters, use the database connection validation utility. For more information about running this utility, see Running the database connection validation utility.

Problem

This issue is most prevalent for utilities that take these passwords as input on the command line, then try to pass them on as is. Examples of such utilities are:
  • setdbtype
  • massload
  • createdb
The following are examples of scenarios where this problem can occur, and the errors you might see.

Scenario #1

When you run the setdbtype command to switch the database to remote a DB2 machine, the build fails. You see an error similar to the following in updatedb.log:
BUILD FAILED
C:\IBM\WCDE_E~1\components\Fixpack\xml\configureDatabaseFixpack.xml:31: The following error occurred while executing this line:
C:\IBM\WCDE_E~1\components\Fixpack\xml\configureDatabaseFixpack.xml:255: com.ibm.db2.jcc.am.SqlInvalidAuthorizationSpecException: [jcc][t4][2013][11249][4.12.55] Connection authorization failure occurred.  Reason: User ID or Password invalid. ERRORCODE=-4214, SQLSTATE=28000

Scenario #2

When you attempt to connect to a DB2 database, you receive an error similar to the following example:
SQL0104N  An unexpected token "!" was found following "<identifier>".
Expected tokens may include:  "NEW".  SQLSTATE=42601

Solution

When you perform operations where the database passwords must be provided on the command line, limit the characters that are used in the DB2 password to the following characters:
  • The letters A through Z, and a through z, as defined in the basic (7-bit) ASCII character set.
  • 0 - 9
  • @ # $
  • _ (underscore). (period): (colon); (semi-colon) \ (backslash) / (forward-slash)
  • & * % - ~ ? + < > = ` [ ] | ^ { }

Some of these characters might correspond to special characters on certain operating systems and therefore must be escaped. For example, on UNIX, the $ character must be escaped like this character: \$