1

Im trying to save Mandarin characters into Oracle instance database 11g. Field datatype - NVARCHAR2 ; NLS_LANG - AMERICAN_AMERICA.WE8ISO8859P1

If I change NLS_LANG, it will affect other data already in this huge database but I need it to support manadarin as well. Im also searching for some way if available on JAVA side while inserting these characters into DB. Please help.

  • 2
    NLS_LANG is not relevant here. Relevant is which character set you chose for the NVARCHAR when the instance was initialized – a_horse_with_no_name Jul 8 '19 at 17:51
1

Changing the NLS_LANG value does not affect any data in the database. However setting character set to WE8ISO8859P1 will not work.

When you set NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1 then you tell the database "The client uses character set WE8ISO8859P1." Thus any Mandarin characters will not be accepted by the database because they are not supported by WE8ISO8859P1.

Use AL32UTF8 or any other character set which supports Mandarin, for example ZHS32GB18030

Apart from that, Java does not use the NLS_LANG setting at all, see Database JDBC Developer's Guide - Globalization Support:

Starting from Oracle Database 10g, the NLS_LANG variable is no longer part of the JDBC globalization mechanism. The JDBC driver does not check NLS environment. So, setting it has no effect.

Please have a look at this document how to setup Unicode in Java environment.

Of course, the database NCHAR Character Set has to support Mandarin. Usually this is set to default AL16UTF16, so I assume that's not the issue here.

| improve this answer | |
  • Thanks for this. I have NLS_NCHAR_CHARACTERSET = AL16UTF16 . Should this help in saving mandarin characters? Just for information, if I directly edit, copy-paste mandarin into NVARCHAR2 field of DB, then it displays as it is on screen, The problem is only in saving. I have another test DB where NLS_CHARACTERSET = AL32UTF8 , but there also Im not able to save mandarin. I guess there might be some JDBC driver settings change also required. – surm Jul 9 '19 at 10:42
  • Yes, AL16UTF16 is fine. But AL32UTF8 is also fine. Sorry, I am not familiar with Java where I could help you. – Wernfried Domscheit Jul 9 '19 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.