Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clob Cyrillic woes

 
Ken Sloane
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was wondering if anyone knew what was going on? I'm having trouble retrieiving Cyrillic characters from a Clob data type from an Oracle 10g database. Using iSQL*Plus web interface I insert Cyrillic text into the database and verify that it looks ok by doing a select on those rows.

In my code, when I attempt to retrieve the data I get a string of question marks. Western European characters seem to work fine.

The code is as follows (I've tried many different methods):

Clob clob = (Clob)(resultSet).getClob(column);
char buffer[] = new char[1];
BufferedReader reader = new BufferedReader(clob.getCharacterStream());
while (reader.read(buffer) != -1) {
data += new String(buffer);
}
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you see ??? instead of the characters you expected to see, that's a sign that the wrong encoding (charset) is being used to convert bytes to chars at some point. Now, you are using getCharacterStream(), so it's the database driver that is returning characters (not bytes) to your program. And it's not converting them correctly.

So probably the solution is to configure the database driver, or the database, to use the correct encoding. You'd have to check the Oracle documentation (or the driver documentation if it isn't an Oracle driver) to find out how to do that.
 
Ken Sloane
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll look at the driver (we're using ojdbc14.jar) and at the database. Thanks. I'll start there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic