问题
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
回答1:
Try following:
- Check that NLS_LANG setting is correct. On windows it is in registry under
\HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
. - Check that Oracle client software is correctly installed.
- Check if there are multiple Oracle homes on that computer. In that case, find active one and check if it works.
- 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>);
回答2:
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).
回答3:
For Windows env, you need to change the System Locale and System Format
to English/US
.
How to change system locale?
回答4:
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
回答5:
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.
回答6:
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.
回答7:
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.
回答8:
check the JAVA_HOME system variable and verify that it is the same version you are using in your projects and programs
回答9:
If you are compiling with intelljIDE I advise you add following options in VMoptions found in configurations model
AddVMOption -Duser.region=us.
回答10:
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.
来源:https://stackoverflow.com/questions/1629327/ora-00604-ora-12705