In both the cases ,ie when the DB2 Connect and the java prog are on the same box and when they are on different boxes.I always specify the hostname of the server on which the DB2 Connect is located to make a connection to the database.
However it works only in the case when the java prog and the DB2 Connect are located on the same machine.
In the second case when they are located on different boxes ,Every time the java prog connects to the DB2 Connect an entry is placed in the $DB2_CONNECT_HOME/db2/jdbcerr.log
"(Fri Feb 06 11:32:23 2004) pid= 936 jdbcServer(jdbcAuthorizeClient): (): The client token, (), and server token, (V), do not match at index, (0) , einfo= 32 (client IP = 10.48.139.69)"