oracle ORA-01882: 未找到时区区域

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9156379/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 03:55:53  来源:igfitidea点击:

ORA-01882: timezone region not found

oraclejdbctimezone

提问by ndalama

I'm accessing an Oracle Database from a java application, when I run my application I get the following error:

我正在从 Java 应用程序访问 Oracle 数据库,当我运行我的应用程序时,出现以下错误:

java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1 ORA-01882: timezone region not found

java.sql.SQLException: ORA-00604: 递归 SQL 级别 1 发生错误 ORA-01882: 时区区域未找到

采纳答案by Matteo Steccolini

You may also try to check the version of the Oracle jdbc driver and Oracle database. Just today I had this issue when using ojdbc6.jar (version 11.2.0.3.0) to connect to an Oracle 9.2.0.4.0 server. Replacing it with ojdbc6.jar version 11.1.0.7.0 solved the issue.

您也可以尝试检查Oracle jdbc 驱动程序和Oracle 数据库的版本。就在今天,我在使用 ojdbc6.jar(版本 11.2.0.3.0)连接到 Oracle 9.2.0.4.0 服务器时遇到了这个问题。用 ojdbc6.jar 版本 11.1.0.7.0 替换它解决了这个问题。

I also managed to make ojdbc6.jar version 11.2.0.3.0 connect without error, by adding oracle.jdbc.timezoneAsRegion=falsein file oracle/jdbc/defaultConnectionProperties.properties (inside the jar). Found this solution here

通过添加oracle.jdbc.timezoneAsRegion=false文件 oracle/jdbc/defaultConnectionProperties.properties(在 jar 中),我还设法使 ojdbc6.jar 版本 11.2.0.3.0 无错误地连接。在这里找到了这个解决方案

Lastly, one can add -Doracle.jdbc.timezoneAsRegion=falseto the command line, or AddVMOption -Doracle.jdbc.timezoneAsRegion=falsein config files that use this notation

最后,可以添加-Doracle.jdbc.timezoneAsRegion=false到命令行,或-Doracle.jdbc.timezoneAsRegion=false使用此表示法的配置文件中的AddVMOption

回答by Marcus Rickert

In a plain a SQL-Developer installation under Windows go to directory

在 Windows 下的普通 SQL-Developer 安装中,转到目录

C:\Program Files\sqldeveloper\sqldeveloper\bin

and add

并添加

AddVMOption -Duser.timezone=CET

to file sqldeveloper.conf.

归档sqldeveloper.conf

回答by Waruna Sri Jayanth

Error I got :

我得到的错误:

Error from db_connection.java -->> java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1 ORA-01882: timezone region not found

来自 db_connection.java 的错误 -->> java.sql.SQLException: ORA-00604: 递归 SQL 级别 1 发生错误 ORA-01882: 找不到时区区域

ORA-00604: error occurred at recursive SQL level 1ORA-01882: timezone region not found

ORA-00604: 在递归 SQL 级别 1 发生错误ORA-01882: 找不到时区区域

Prev code:

上一个代码:

 public Connection getOracle() throws Exception {
     Connection conn = null;
     Class.forName("oracle.jdbc.driver.OracleDriver");
     conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:tap", "username", "pw");
     return conn;
}

new Code:

新代码:

 public Connection getOracle() throws Exception {
     TimeZone timeZone = TimeZone.getTimeZone("Asia/Kolkata");
     TimeZone.setDefault(timeZone);
     Connection conn = null;
     Class.forName("oracle.jdbc.driver.OracleDriver");
     conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:tap", "username", "pw");
     return conn;
}

now it is working!!

现在它正在工作!!

回答by Babatunde Adeyemi

Update the file oracle/jdbc/defaultConnectionProperties.propertiesin whatever version of the library (i.e. inside your jar) you are using to contain the line below:

更新文件oracle/jdbc/defaultConnectionProperties.properties在您使用的任何版本的库中(即在您的 jar 中)以包含以下行:

oracle.jdbc.timezoneAsRegion=false

回答by eckes

What happens is, that the JDBC client sends the timezone ID to the Server. The server needs to know that zone. You can check with

发生的情况是,JDBC 客户端将时区 ID 发送到服务器。服务器需要知道该区域。你可以检查

SELECT DISTINCT tzname FROM V$TIMEZONE_NAMES where tzname like 'Etc%';

I have some db servers which know about 'Etc/UTC' and 'UTC' (tzfile version 18) but others only know 'UTC' (tz version 11).

我有一些数据库服务器知道“Etc/UTC”和“UTC”(tzfile 版本 18),但其他服务器只知道“UTC”(tz 版本 11)。

SELECT FILENAME,VERSION from V$TIMEZONE_FILE;

There is also different behavior on the JDBC client side. Starting with 11.2 the driver will sent the zone IDs if it is "known" to Oracle, whereas before it sent the time offset. The problem with this "sending of known IDs" is, that the client does not check what timezone version/content is present on the server but has its own list.

JDBC 客户端也有不同的行为。从 11.2 开始,如果 Oracle 为“已知”,驱动程序将发送区域 ID,而在发送时间偏移之前。这种“发送已知 ID”的问题在于,客户端不会检查服务器上存在的时区版本/内容,而是有自己的列表。

This is explained in Oracle Support Article [ID 1068063.1].

这在 Oracle 支持文章 [ID 1068063.1] 中有解释。

It seems it also depends on the Client OS, it was more likely that Etc/UTC fails with Ubuntu than RHEL or Windows. I guess this is due to some normalization but I haven't figured out what exactly.

似乎它也取决于客户端操作系统,与 RHEL 或 Windows 相比,Ubuntu 的 Etc/UTC 失败的可能性更大。我想这是由于一些规范化,但我还没有弄清楚到底是什么。

回答by Priyan at Dialog

  1. in eclipse go run- > run configuration

  2. in there go to JREtab in right side panels

  3. in VM Argumentssection paste this

    -Duser.timezone=GMT

  4. then Apply - > Run

  1. 在 Eclipse 中运行->运行配置

  2. 在那里转到右侧面板中的JRE选项卡

  3. VM Arguments部分粘贴此内容

    -Duser.timezone=GMT

  4. 然后应用->运行

回答by Matt

I had this problem when running automated tests from a continuous integration server. I tried adding the VM argument "-Duser.timezone=GMT" to the build parameters, but that didn't solve the problem. However, adding the environment variable "TZ=GMT" did fix it for me.

从持续集成服务器运行自动化测试时遇到了这个问题。我尝试-Duser.timezone=GMT在构建参数中添加 VM 参数“ ”,但这并没有解决问题。但是,添加环境变量“ TZ=GMT”确实为我修复了它。

回答by Guna Sekaran

ERROR :

错误 :

ORA-00604: error occurred at recursive SQL level 1 ORA-01882: timezone region not found

ORA-00604: 递归 SQL 级别 1 发生错误 ORA-01882: 找不到时区区域

Solution: CIM setup in Centos.

解决方案:在 Centos 中设置 CIM。

/opt/oracle/product/ATG/ATG11.2/home/bin/dynamoEnv.sh

Add this java arguments:

添加此 java 参数:

JAVA_ARGS="${JAVA_ARGS} -Duser.timezone=EDT"

回答by Babatunde Adeyemi

In Netbeans,

在 Netbeans 中,

  1. Right-click your project -> Properties
  2. Go to Run (under Categories)
  3. Enter -Duser.timezone=UTC or -Duser.timezone=GMT under VM Options.
  1. 右键单击您的项目 -> 属性
  2. 转到运行(在类别下)
  3. 在 VM 选项下输入 -Duser.timezone=UTC 或 -Duser.timezone=GMT。

Click Ok, then re-run your program.

单击“确定”,然后重新运行您的程序。

Note: You can as well set to other timestones besides UTC & GMT.

注意:您也可以设置除 UTC 和 GMT 之外的其他时间石。

回答by bonh

I ran into this problem with Tomcat. Setting the following in $CATALINA_BASE/bin/setenv.shsolved the issue:

我在使用 Tomcat 时遇到了这个问题。设置以下$CATALINA_BASE/bin/setenv.sh解决了这个问题:

JAVA_OPTS=-Doracle.jdbc.timezoneAsRegion=false

I'm sure that using one of the Java parameter suggestions from the other answers would work in the same way.

我确信使用其他答案中的 Java 参数建议之一会以相同的方式工作。