Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NLS_LANG setting for JDBC thin driver?

I am using the thin Oracle JDBC driver ver 10.2.0 (ojdbc14.jar). I would like to configure its NLS_LANG setting manually. Is there a way?

Currently it fetches this setting from the VM variable user.language (which is set automatically by setting the current locale, or on startup from the system environment).

This is a problem when the users switch the application locale to a one that is unsupported by the Oracle JDBC driver (e.g. mk_MK). In this case, the next time I fetch a connection I get the following exception:

 ORA-00604: error occurred at recursive SQL level 1 ORA-12705: Cannot access NLS data files or invalid environment specified 

I can change the locale on the fly just before I fetch the connection and switch back to the user's selected one back and forth, but this seems unelegant and unefficient.

like image 711
dasp Avatar asked Jul 03 '09 16:07

dasp


People also ask

What is thin driver in JDBC?

The JDBC Thin driver is a pure Java, Type IV driver that can be used in applications and applets. It is platform-independent and does not require any additional Oracle software on the client-side. The JDBC Thin driver communicates with the server using SQL*Net to access Oracle Database.

What is Nls_lang?

NLS_LANG Parameter Fundamentals Setting the NLS_LANG environment parameter is the simplest way to specify locale behavior for Oracle software. It sets the language and territory used by the client application and the database server.

Why Thin driver is preferred for JDBC?

Thin driver directly converts the JDBC calls into vendor database specific protocols without any intermediate transformation. It is implemented using Java. Advantages: faster performance compared to the other drivers.


1 Answers

See also: https://serverfault.com/questions/63216/ora-12705-cannot-access-nls-data-files-or-invalid-environment-specified/64536

For me the best response was by FoxyBOA to invoke java app with:

-Duser.country=en -Duser.language=en 
like image 187
Michał Niklas Avatar answered Sep 20 '22 13:09

Michał Niklas