How to set the timezone region for JDBC Connection and avoid the SqlException timezone region not found?(如何为 JDBC Connection 设置时区,避免找不到 SqlException 时区?)
问题描述
我在尝试创建 Connection 对象以处理来自命令行 Java 应用程序和 Oracle 数据库的连接时遇到以下问题.
I have the following problem trying to create a Connection object to handle the connection from a command line Java application and an Oracle database.
所以我有一个包含 main() 方法的 Main 类,这个:
So I have a Main class that contains the main() method, this one:
问题是当我尝试执行此指令时:
The problem is that when I try to perform this instruction:
我得到这个异常:
所以,我记得在使用此数据库的其他一些应用程序中,有必要设置时区或类似的东西(但现在我无法访问这些应用程序).
So, I remember that in some other applications that works with this DB it was necessary to set the timezone or something like this (but now I can't access to these applications).
那么,我该如何解决这个问题?我可以以编程方式为我的 Connection 设置时区吗?
So, how can I fix this issue? Can I set programmatically the timezone for my Connection?
Tnx
推荐答案
在尝试连接之前写下:
所以整个代码是:
如果这不起作用,则问题可能是无效的 JDBC 驱动程序版本.
If this does not work, the problem may be an invalid JDBC driver version.
这篇关于如何为 JDBC Connection 设置时区,避免找不到 SqlException 时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!