Assuming that thefollowing three strings make up a word in chinese how do i store al开发者_开发技巧l these together in a single field(as one word) in the oracle
String code="\u6B32 ";
String code1="\u8ECE";
String code2="\u4F7F";
Thank you
You can simply set the string as the parameter of a JDBC PreparedStatement. To store Unicode you will need ask your DBA to ensure that the Oracle instance is created using a Unicode character set such as UTF-8 (or, alternatively, that the NVARCHAR type uses a Unicode character set).
Suggested Oracle settings:
- NLS_CHARACTERSET: AL32UTF8
- NLS_LENGTH_SEMANTICS: CHAR
You can check the NLS parameters by issuing the following query:
select * from v$nls_parameters
Since you will be saving Chinese characters I suggest you read up on Unicode supplementary characters and their implementation in Oracle DB. Each Unicode character set stores supplementary characters differently, and this can have a significant affect on the size of your DB on disk. Also, length semantics can be more complicated because there is no longer a 1:1 relationship between # of code points and # of characters.
Further reading:
- Choosing a Character Set
- Supporting Multilingual Databases with Unicode
- Java Programming in a Global Environment
- Collation in Oracle using NLS_SORT
This should be enaugth
String word = "\u6B32\u8ECE\u4F7F";
PreparedStatement pstmt = pstmt = conn.prepareStatement("INSERT INTO MY_TABLE(WORDS) VALUES(?)");
pstmt.setString(1, word);
pstmt.execute();
pstmt.close();
精彩评论