IBM Support

Username or password with special characters must be quoted when using them through the CLP

Question & Answer


Question

SQL0104N might be received when making a connection to the database through the command line processor if the username or password contains a special character. For example,
 
db2 => CONNECT TO sample USER admin USING !xyz
SQL0104N An unexpected token "!" was found following "". Expected tokens may include: "NEW". SQLSTATE=42601 

Answer

It is recommended to quote usernames and passwords that use any special characters except from the following character set:
 
A-Z, a-z (ALPHABETIC CHARACTERS)
# $ @ (DIAMOND "LETTERS")
0-9 (NUMERIC CHARACTERS)
_ (UNDERSCORE CHARACTER)
. (PERIOD CHARACTER)
/ (FORWARD SLASH CHARACTER)
\ (BACKWARD SLASH CHARACTER)
: (COLON CHARACTER)
& * % - ~ + ; ? < = > [ ] ` | ^ { }

 
The following command is an example for quoting a user's password inside the Db2 prompt:
 
db2 => CONNECT TO sample USER admin USING '!xyz'
Outside of the Db2 prompt, extra double quotation marks might need to be used to prevent the shell from interpreting special characters as part of the command. Either the password or the entire command can be quoted.
db2 connect to sample USER admin USING "'!xyz'"

or

db2 "connect to sample USER admin USING '!xyz'"
Alternatively, use the password prompt feature by executing a CONNECT statement without providing a password. In the password prompt, passwords containing special characters do not need to be quoted.
db2 => CONNECT TO sample USER admin

or

db2 CONNECT TO sample USER admin

 

[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"ARM Category":[{"code":"a8m500000008PmmAAE","label":"Security and Plug-Ins-\u003EAuthentication"}],"ARM Case Number":"","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"All Versions"}]

Document Information

Modified date:
22 September 2022

UID

swg21303153