«

»

May 24 2004

Print this Post

gethostbyname pays attention to blanks?

I was working on my current project at work today and ran into an odd problem … a host name (that existed) could not be resolved.

The only different thing about the host name is that it was retrieved from an iSeries using JDBC.

I could ping the host without a problem … so I knew it was valid, but the “InetAddress.getByName()” method couldn’t resolve it.

After a while I noticed that the ending quote for the host name field wasn’t showing up in the variable debug window (of WDSC). So I added a “String.trim()” to the end of the “ResultSet.getString()” and getByName() was able to resolve the name.

I would have thought that getByName() would be able to deal with blanks on the end of a host name.

css.php