String outStr = new String(rs.getBytes(1),"ISO-8859-1");
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).
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment