如何在Oracle JDBC数据库URL中设置ServertimeZone?
当我尝试使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的服务器时区是:
命令: timEdatectl
,在oracle中是:
:从dual; 中选择dbtimezone;
,所以我必须在application上进行更改。
sql 到Oracle文档时,当TimeZoneAsregion设置为True时,它使用默认的JVM TimeZone而不是转换为GMT偏移量。
My server timezone was:
Command: timedatectl
And in Oracle was:
Sql:SELECT DBTIMEZONE FROM dual;
So I have to change on application.properties to put timezoneAsRegion to false:
According to Oracle documentation when timezoneAsRegion is set to true it uses default JVM timezone rather than convert to a GMT offset.