i have inserted Chinese character into oracle database. but the value is not suitable with the character, the value such as ¿¿ :¿¿¿!. the data type is varchar2. same problem when i want to display the data. How to store and display Chinese character into oracle 10g database ?
Asked
Active
Viewed 5,344 times
0
-
3What is the database character set (`select * from v$nls_parameters`)? What is the client `NLS_LANG`? What is the client code page? What application are you using to insert the data? What application are you using to view the data? – Justin Cave Jul 01 '14 at 23:24
-
Kindly visit this [link](http://stackoverflow.com/questions/303178/how-do-i-insert-chinese-characters-into-a-sqlexpress-text-field) it might help. – michikot Jul 01 '14 at 23:43
-
Provide us the character sets of the database and the client (application, terminal, etc. ...) you use to insert data. One of them might have less characters than another. – neshkeev Jul 02 '14 at 06:43
1 Answers
0
To support unicode character use driver Properties as shown :-
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@10.52.45.36:1521:ORCL";
Properties connectionProps = new Properties();
connectionProps.put("useUnicode","true"); //Property 1
connectionProps.put("characterEncoding","UTF-8" ); //Property 2
connectionProps.put("user", "SYSTEM");
connectionProps.put("password", "Root-123");
Connection conn = DriverManager.getConnection(url,connectionProps);
Statement stmt = conn.createStatement();
And ensure that the datatype in the oracle table is NVARCHAR/NCHAR. Also, while inserting use function such as TO_NCHAR('-some-unicode-value-') or N'-some-unicode-value-'
This should be it!

Suraj
- 407
- 1
- 8
- 12