My blog has moved! Redirecting...

You should be automatically redirected. If not, visit http://mindsiview.wordpress.com/ and update your bookmarks.

Friday, June 11, 2004

Java Quick Tip Of the Day: Character Encoding and ResultSets

We recently ran into a problem where a Java program running on our IBM enterprise server was unable to properly display strings returned from a Microsoft SQL Server table. The problem was due to character encoding. Because of the SQL Server table definition, the JDBC driver was not translating the ASCII values in the string returned from a ResultSet.getString() method to EBCDIC. The solution. Explicitly define the encoding by casting the returned value of a ResultSet.getBytes() into a String (see below).
String outStr =  new String(rs.getBytes(1),"ISO-8859-1");

No comments:

Technorati search