3

I am using JPA to access an Oracle database which has its encoding set to ISO-8859-1.

How do I set NLS_LANG using JPA to receive data in the correct encoding?

I suspect it should be set somewhere in the persistence context XML.

Jan Algermissen
  • 4,930
  • 4
  • 26
  • 39
  • You should **not** rely on a special value for NLS_LANG (and the implicit conversion that comes with it). Use the approriate format masks e.g. in `to_date()` or `to_char()` –  Jan 17 '12 at 09:17

1 Answers1

2

The JDBC driver takes care of everything. It knows what the encoding value is and uses the appropriate encoding without any action on your part.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • 1
    AFAIK the driver uses the default locale from the JVM (which can be set using `-Duser.locale`) - but still: no production code should ever rely on a specific setting for NLS_LANG –  Jan 17 '12 at 09:56
  • You're probably right. My answer was more concerned with the encoding. I'll edit it to make it clearer. – JB Nizet Jan 17 '12 at 09:59
  • Thanks. I caused the special characters to be wrong myself. Hence no need to try to change connection settings anymore. – Jan Algermissen Jan 26 '12 at 13:01