Issue while reading Chinese Character from Oracle DB

Hi all

I'm facing some issue while reading chinese character from Oracle DB.

We are able to store the string 中纪委正积极组建国家. But while reading it back one char is replaced by ?. 中纪委正积�?组建国家

In database I can find the proper unicoded values sored. Following are the statements used for read/wie to DB.

Write to DB:

preparedStmt.setString(1, new String(paramValue.getBytes("UTF-8")));

Read From DB

String paramValue=rs.getString("CHINESE_COL");

String utfValue = new String(paramValue.getBytes(),"UTF-8");

My test client is a swing based client with chinese font settings running on JRE 1.4.

Oracle DB settings are given below.

PARAMETER VALUE

-

NLS_LANGUAGEAMERICAN

NLS_TERRITORYAMERICA

NLS_CURRENCY$

NLS_ISO_CURRENCYAMERICA

NLS_NUMERIC_CHARACTERS .,

NLS_CHARACTERSETUTF8

NLS_CALENDARGREGORIAN

NLS_DATE_FORMATDD-MON-RR

NLS_DATE_LANGUAGE AMERICAN

NLS_SORTBINARY

NLS_TIME_FORMATHH.MI.SSXFF AM

PARAMETER VALUE

-

NLS_TIMESTAMP_FORMATDD-MON-RR HH.MI.SSXFF AM

NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR

NLS_TIMESTAMP_TZ_FORMATDD-MON-RR HH.MI.SSXFF AM TZR

NLS_DUAL_CURRENCY $

NLS_COMPBINARY

NLS_LENGTH_SEMANTICSBYTE

NLS_NCHAR_CONV_EXCPFALSE

NLS_NCHAR_CHARACTERSET UTF8

NLS_RDBMS_VERSION 10.2.0.1.0

What has gone wrong?Can anybody help me on this?

Thanks

Jobinesh

null

[1497 byte] By [Jobinesha] at [2007-11-27 5:05:32]
# 1

I don't use Oracle, but I'd like to share with you my limited knowledge on MySQL. Hope that could give you some idea.

When I insert data into MySQL tables, I DON'T convert strings to UTF-8 beforehand. However, I make sure that all my tables were created to support UTF-8 as string encoding. Then the Java code is something like this.

String lname = "陳";

String fname = "小明";

String url = "jdbc:mysql://server_name/mydatabase?user=some_name&password=some_pass";

Class.forName("com.mysql.jdbc.Driver"); // loading the JDBC driver

Connection con = DriverManager.getConnection(url);

// the most important part follows

PreparedStatement stmt = con.prepareStatement(

"insert into mytable(lastname,firstname) values (?,?)");

// "mytable" table is supposed to have two columns for first name and last name.

stmt.setString(1, lname);

stmt.setString(2, fname);

stmt.executeUpdate();

stmt.close();

con.close();

That's it! That's all I do and it works perfectly for me.

horiniusa at 2007-7-12 10:24:01 > top of Java-index,Desktop,I18N...