0

I just found out that creating a connection to Oracle using JDBC Thin driver version 10.2.0.4 fails when the Locale is set to empty string, for example :

Locale.setDefault(new Locale("",""));
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection(url, userName, password);     

The above code will produce ORA-12705: Cannot access NLS data files or invalid environment specified. It works fine if I specify en US, or just en.

But if I use Oracle driver 9.2.0.1, this exact piece of code works : the NLS is set to AMERICAN.

My question is : Is this a normal, documented, change of behavior ? Maybe setting default locale to empty strings is a bad practice ?

neirda
  • 163
  • 6

1 Answers1

0

if you have access to oracle support, note 115001.1 seems to state there are changes around this from 10g onwards:

9i Thick JDBC (=OCI) driver will make use of the NLS_LANG to determine the how to convert characters. NOT defining the NLS_LANG will make this to use the default US7ASCII setting, any non-ASCII data from /to the database will be lost.

You don't need to specify anything to your Java code for JDBC to pick up the NLS_LANG.

From 10g onwards the Thick JDBC driver is ignoring the NLS_LANG and uses Language, Territory and characterset settings from the JVM locale.

In 11g the property -Doracle.jdbc.ociNlsLangBackwardCompatible=true is settable on the command. If set it causes JDBC to get the characterset from NLS_LANG instead of getting the client characterset id from the locale.

Language and territory are taken from the locale regardless of the property though.

DazzaL
  • 21,638
  • 3
  • 49
  • 57
  • Thanks for your input. But in this case I am referring to the thin driver, which does not rely on a NLS_LANG variable, only on the JVM locale if I am correct. I have edited my question to specify I am talking about Thin driver. – neirda Nov 20 '12 at 16:56