ORA-00604 ORA-12705

发布于 2024-08-08 23:32:05 字数 1865 浏览 8 评论 0原文

我的 j2ee Web 应用程序中出现此错误。

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)

这个项目在我同事的电脑上工作...我的意思是这个项目适用于他们,但是当我询问他们的项目文件夹并将其导入到我的 eclipse 上时,当我运行它时,我遇到了这个错误。 jar 文件已经打包到项目文件夹中。

我还使用 hibernate 创建了一个简单的 j2ee 项目,但我遇到了同样的错误。 我尝试 ping 数据库服务器并使用 PL/SQL Developer 浏览它,但没有任何问题

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

沉睡月亮 2024-08-15 23:32:05

请尝试以下操作:

  1. 检查 NLS_LANG 设置是否正确。在 Windows 上,它位于 \HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE 下的注册表中。
  2. 检查Oracle客户端软件是否安装正确。
  3. 检查该计算机上是否有多个 Oracle 主目录。在这种情况下,找到活动的并检查它是否有效。
  4. 如果已安装,请使用 SQL*Plus 进行测试。 Sql Developer 之所以能够工作,是因为它有自己的客户端安装。

编辑:
关于驱动程序,请检查此站点:Oracle Instant Client。在那里您将找到有关 JDBC 访问 Oracle 所需的最低驱动程序安装的文档。我对此不太了解,因为我使用.Net。

编辑2:
请参阅此问题:JDBC 瘦驱动程序的 NLS_LANG 设置。存在与您相同的错误,问题是未定义 NLS LANG 的默认区域设置。引用:

NLS_LANG 设置源自 java.util.Locale 。因此,在连接之前您需要进行类似的调用:

  Locale.setDefault(Locale.<your locale here>);

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>);
冷心人i 2024-08-15 23:32:05

我发现您可以将这两个参数传递给 Java 应用程序来解决问题:

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

您也可以在环境变量级别配置值(取决于您的操作系统)。

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).

眼藏柔 2024-08-15 23:32:05

我也有同样的问题。解决方案是将国家/地区和语言添加到 sqldeveloper.conf

请打开文件:

\sqldeveloper\sqldeveloper\bin\sqldeveloper.conf

并添加以下内容:

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

上面的方法可以解决问题。

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

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

羁拥 2024-08-15 23:32:05

对于 Windows 环境,您需要将系统区域设置和系统格式更改为英语/美国

如何更改系统区域设置?

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

How to change system locale?

魂牵梦绕锁你心扉 2024-08-15 23:32:05

我找到了解决方案,我只需更改操作系统(Windows 7)中的区域和语言,确保它与 Oracle 区域和语言匹配。

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.

荒芜了季节 2024-08-15 23:32:05

Oracle JDBC 驱动程序在打开新连接后隐式执行以下语句:

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

在我们的例子中,我们遇到了 Oracle XE 11g 和嵌入到 JDBC 驱动程序中的默认语言/区域映射的问题:“ru”区域设置被映射到仅由 Oracle 支持的“CIS”区域EE,但 Oracle XE 仅具有“俄罗斯”领土。
以下是我们修复此问题的方法:

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

有 NLS_LANGUAGE 选项(默认设置没有问题):

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

修复:从 java jdbc 驱动程序的 oracle.sql.converter.CharacterSetMetaData 类获取的常量 ru=RUSSIAN

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.

阳光下的泡沫是彩色的 2024-08-15 23:32:05

如果您使用 intelljIDE 进行编译,我建议您在配置模型中找到的 VMoptions 中添加以下选项

AddVMOption -Duser.region=us. 

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

AddVMOption -Duser.region=us. 
甜尕妞 2024-08-15 23:32:05

首先执行查询:

select userenv('LANGUAGE') from dual;`

这将给出oracle区域和语言。更改操作系统中的区域和语言,两者应该匹配。

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.

半边脸i 2024-08-15 23:32:05

检查 JAVA_HOME 系统变量并验证它是否与您在项目和程序中使用的版本相同

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

情徒 2024-08-15 23:32:05

更改我的机器的区域设置和语言有助于解决这个问题。
我将区域更改为美国,并将英语(美国)更改为语言。

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.

离鸿 2024-08-15 23:32:05

如果您正在运行 Spring 应用程序,只需添加 Locale.setDefault(Locale.ENGLISH);在主课上。

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



}

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);



}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文