如何在Oracle JDBC数据库URL中设置ServertimeZone?

发布于 2025-02-11 12:24:45 字数 1276 浏览 0 评论 0原文

当我尝试使用Oracle Connection启动Spring-Boot应用程序时,我会遇到错误:

csm-security              | 2022-06-29 19:26:21.571  INFO [csm-security,,] 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2402 ms
csm-security              | 2022-06-29 19:26:22.329  INFO [csm-security,,] 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
csm-security              | 2022-06-29 19:26:23.847 ERROR [csm-security,,] 1 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.
...
csm-security              | java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
csm-security              | ORA-01882: timezone region not found

我尝试将 usetimezone servertimezone 没有用:

spring.datasource.url=jdbc:oracle:thin:@192.1..1.1:1521:desastg?useTimezone=true&serverTimezone=UTC

我也试图将其放在:

spring.datasource.hikari.data-source-properties.oracle.jdbc.timezoneAsRegion=true

spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.jpa.properties.hibernate.jdbc.time_zone=UTC

I'm getting an error when I try to start a spring-boot application with Oracle connection:

csm-security              | 2022-06-29 19:26:21.571  INFO [csm-security,,] 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2402 ms
csm-security              | 2022-06-29 19:26:22.329  INFO [csm-security,,] 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
csm-security              | 2022-06-29 19:26:23.847 ERROR [csm-security,,] 1 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.
...
csm-security              | java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
csm-security              | ORA-01882: timezone region not found

I've tried to put useTimezone and serverTimezone on my application.properties but it didn't work:

spring.datasource.url=jdbc:oracle:thin:@192.1..1.1:1521:desastg?useTimezone=true&serverTimezone=UTC

I've also tried to put this:

spring.datasource.hikari.data-source-properties.oracle.jdbc.timezoneAsRegion=true

spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.jpa.properties.hibernate.jdbc.time_zone=UTC

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

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

发布评论

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

评论(1

那片花海 2025-02-18 12:24:45

我的服务器时区是:

命令: timEdatectl

Time zone: America/Argentina/Buenos_Aires (-03, -0300)

,在oracle中是:

从dual; 中选择dbtimezone;

+00:00

,所以我必须在application上进行更改。

spring.datasource.hikari.data-source-properties.oracle.jdbc.timezoneAsRegion=false

sql 到Oracle文档时,当TimeZoneAsregion设置为True时,它使用默认的JVM TimeZone而不是转换为GMT偏移量。

My server timezone was:

Command: timedatectl

Time zone: America/Argentina/Buenos_Aires (-03, -0300)

And in Oracle was:

Sql:SELECT DBTIMEZONE FROM dual;

+00:00

So I have to change on application.properties to put timezoneAsRegion to false:

spring.datasource.hikari.data-source-properties.oracle.jdbc.timezoneAsRegion=false

According to Oracle documentation when timezoneAsRegion is set to true it uses default JVM timezone rather than convert to a GMT offset.

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