ResultSet's getString method returns ? (question marks) when the string contains multibyte characters

1.2k Views Asked by At

The database is oracle 11gR2 and the charset of the database is AL32UTF8 and the column I'm trying to query is NVARCHAR2.

ResultSet rs = statement.executeQuery(query);
while (oRS.next())
        {
            String s = oRS.getString(1);
            System.out.println(s);
        }

All the non-English multi byte characters are displayed as question marks. I tried replacing the getString with getBytes and tried converting the byte array to String with "UTF-8" charset, no luck.

My intention was not to print on the console, but I am embedding this list of strings to a HTML file (a list control ). Even there it displays the strings with question marks. The HTML page was encoded with ISO-8859-1

1

There are 1 best solutions below

0
On

I changed the html page's encoding to UTF-8 and it started working. So the problem was not with the JDBC.