You didn't specify your platform/language, so here are a few ideas.
If you're using Java and Direct connect, the IBM documentation on this can be found here. If it can be done, this is the place to look.
OR for any language that can use ODBC (including .NET. VB6, VBSCRIPT, etc) you can set it up via ODBC, and have the username/password there.
http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.cli.doc/doc/r0021682.htm
And finally, in case these don't work because they don't apply to you, and you're using .NET, if the problem is that you don't want the username and password to be readable in the config file, you can always store part or all of the connection string in the registry to make it more difficult, as described here: http://support.microsoft.com/kb/891028
Hopefully one of these options will work for you.