12

I am having this error in my j2ee web application.

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

 oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
 oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
 oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:283)
 oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:278)
 oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:785)
 oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:376)
 oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
 oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
 oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
 oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:839)
 java.sql.DriverManager.getConnection(Unknown Source)
 java.sql.DriverManager.getConnection(Unknown Source)
 org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
 org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
 org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
 org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
 org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
 org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1353)


 org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
 org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1353)

This project works in my colleagues' PCs... I mean this project works for them but when I asked for their project folder and imported it on my eclipse, when i run it i meet this error. The jar files are already packaged with the project folder.

I also created a simple j2ee project using hibernate but I had the same error. I tried to ping the DB server and browse it using PL/SQL developer and I don't have any problem with it

11 Answers 11

8

Try following:

  1. Check that NLS_LANG setting is correct. On windows it is in registry under \HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE.
  2. Check that Oracle client software is correctly installed.
  3. Check if there are multiple Oracle homes on that computer. In that case, find active one and check if it works.
  4. Test with SQL*Plus if there is one installed. Sql Developer works because it has its own client installation.

Edit:
Regarding drivers, check this site: Oracle Instant Client. There you will find documentation on minimum drivers installation needed for JDBC access to Oracle. I don't know much about that because I use .Net.

Edit 2:
See this question: NLS_LANG setting for JDBC thin driver. There is same error as you have and problem was that default locale for NLS LANG was not defined. Quote:

The NLS_LANG settings are derived from the java.util.Locale . Therefore, you will need to make a call similar to this before connecting:

  Locale.setDefault(Locale.<your locale here>);
1
  • Do I have to install an oracle client for my web app to connect? I thought I just need the odbc driver jar included in my project.
    – cedric
    Oct 28, 2009 at 1:59
8

I figured out that that you could pass that two params to your Java app to resolve the issue:

-Duser.country=en -Duser.language=en

You could configure the values at environment variable level as well (depends from your OS).

7

I had the same problem. The solution was to add the country and the language to sqldeveloper.conf

Please open the file:

\sqldeveloper\sqldeveloper\bin\sqldeveloper.conf

And add the following:

AddVMOption -Duser.language=en
AddVMOption -Duser.region=us

The above does the trick.

Reference: http://forum.oradba.net/showthread.php?t=423&langid=1

3
  • Worked for me. But that is rocket science... I mean how would I guess it...
    – nikita
    Dec 19, 2017 at 15:27
  • You're the governor lol, 2 hours later thank you so much!
    – Joe Mwa
    Nov 24, 2020 at 18:20
  • You saved my day. Dec 23, 2020 at 6:31
5

For Windows env, you need to change the System Locale and System Format to English/US.

How to change system locale?

1

I found solution, I just change the regional and language in my OS (windows 7), make sure it matches with the oracle regional and language.

1

Oracle JDBC driver implicitly executes following statement after opening new connection:

ALTER SESSION SET NLS_LANGUAGE='language' NLS_TERRITORY='territory'

In our case we had problems with Oracle XE 11g and default language/territory mappings embedded into JDBC driver: 'ru' locale was mapped to 'CIS' territory which is supported only by Oracle EE, but Oracle XE had 'RUSSIA' territory only. Here is the way we fixed this:

-Doracle.jdbc.territoryMap="ru=RUSSIA;RU=RUSSIA"

There is option for NLS_LANGUAGE(we had no problems with defaults):

-Doracle.jdbc.languageMap="ru=RUSSIAN;RU=RUSSIAN"

Fixed: constant ru=RUSSIAN taken from class oracle.sql.converter.CharacterSetMetaData of java jdbc driver.

1
  • Thank you for this answer! In my case it was System.setProperty("oracle.jdbc.territoryMap", "ru=RUSSIA;RU=CIS"); assignment that solved the problem (for the old Oracle9i).
    – Toparvion
    Apr 27, 2020 at 12:43
1

If you are compiling with intelljIDE I advise you add following options in VMoptions found in configurations model

AddVMOption -Duser.region=us. 
0

First execute query:

select userenv('LANGUAGE') from dual;`

This will give oracle regional and language. Change the regional and language in OS, both should match.

0

check the JAVA_HOME system variable and verify that it is the same version you are using in your projects and programs

1
  • you should provide more info about this variable: where to find it? what does it really do? etc.
    – Maciej S.
    Feb 27, 2019 at 22:10
0

Changing the region settings and language of my machine helped to get away with this. I changed region to United States and English (United States) as language.

0

If you are running a spring application just add Locale.setDefault(Locale.ENGLISH); at main class.

public static void main(String[] args) throws Exception
{
    Locale.setDefault(Locale.ENGLISH);
    SpringApplication.run(ApplicationName.class, args);



}

Your Answer

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

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