Our DB2 authentication is integrated with active directory, so the allowed passwords are controlled by it's policy. We have some users that are not being able to connect to the database through Command Editor or the Query screen in Control Center. The error is the following:

SQL0104N  An unexpected token "!" was found following "".  
Expected tokens may include:  "NEW".
 SQLSTATE: 42601
 sqlcode: -104

They are able to connect through Command Line Processor as far as they don't include the password in the connect statement.
The problem is affecting all users with some special characters in their passwords. We had them try issuing the connect statement without the password in Command Editor but it didn't work.
The exact version of the database is DB2/AIX64 9.5.4
Is there a way for them to use this tools other that to have them change their passwords?

  • It may also be worth noting that IBM is deprecating the GUI tools (Control Center and others) packaged with DB2. They are now recommending you use either command line, or download IBM Data Studio which can be downloaded for free, if you wish to use GUI tools. Commented May 30, 2012 at 13:04

3 Answers 3


This is a long-standing bug in the GUI tools.

However, as long as your password does not contain a double quote (") character, then you can work around this by putting double quotes around the password to connect.

connect to sample user test using test!
--> SQL0104N

connect to sample user test using "test!"
--> connection succeeded.

This method will also work if the GUI tools prompt you for a password with a dialog box.

If you have passwords with double quotes in them, you may be out of luck. You could open a ticket with IBM DB2 support and/or just change the password.

  • Thanks! that worked. If anyone comes with a password with " in it we will have him change it, but I don't expect it to be too often. Commented Jun 2, 2011 at 12:55

Enclose your password with special characters within Singlequote, Doublequote pair. Ex: Passwd='"test!"'

This will work for sure.


Write a script with #!/bin/ksh as the first line. Escape the password with combination of single quotes, double quote pair, first line declaration is important.


db2 connect to &db2name& user &username& using "'&password&'"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.