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.

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

1 Answer 1

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.

2
  • 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, 2019 at 10:42
  • Yes, AL16UTF16 is fine. But AL32UTF8 is also fine. Sorry, I am not familiar with Java where I could help you. Jul 9, 2019 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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