Thin jdbc oracle driver and java string problem
Dear all,
I have an utf-8 oracle database storing some chinese and portuguese, when i used thin jdbc driver to query the database table, the returned varchar2 string is not shown correctly in my java program and also my jsp?
Could anyone tell me what's the problem? Do i need to specify the encoding or charset of the java string after getting from database?
Thank you!!
First you need to determine where the problem is.
There are two parts. The driver and the way you are actually displaying it (like via jsp.)
You determine if it is the driver by printing the characters as integers/hex. (You do NOT try to print them as characters.) From the integer values you determine if they have the correct char value.
If yes then the problem is with the display (jsp)
If no then the problem is with the driver.
> My data in the database should be in UTF 8
> and i want to display it as UTF 8 too.
That's all very well, but between the database and the browser the data gets converted into characters (by the DB driver) and then back to bytes (when you send it to the browser from your JSP). Make sure you get BOTH those encodings done correctly.
> thx.......
> If it is really the driver's problem, how can i fix
> it? is it the driver automatically convert my data's
> charset? My data in the database should be in UTF 8
> and i want to display it as UTF 8 too.
I am not going to make any suggestions until you have actually determine where the problem is.
And post the code that you used to determine the problem. And also post how you determine what the character in the database is (the integer value) and what you got when you ran the code.