从 java 问题连接到数据库
connecting to DB from java issue
当我尝试从 IntelliJ 连接到我的数据库时,在我将连接器文件插入模块后,运行 控制台向我发送了这个问题:
Caused by: java.sql.SQLException: The server time zone value
'Jerusalem Daylight Time' is unrecognized or represents more than one
time zone. You must configure either the server or JDBC driver (via
the serverTimezone configuration property) to use a more specifc time
zone value if you want to utilize time zone support.
这是代码:
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/login","root","Password");
System.out.println("Connection: " + con.getCatalog());
谢谢。
在连接 URL :
中指定 MySQL 支持的时区
DriverManager.getConnection("jdbc:mysql://localhost:3306/login?serverTimezone=UTC","root","Password");
使用以下命令设置 mysql 服务器时区,时区将根据您所在的地区而定。
设置time_zone='US/Eastern';
或
设置time_zone = '-6:00';
它可能会解决您的问题
当我尝试从 IntelliJ 连接到我的数据库时,在我将连接器文件插入模块后,运行 控制台向我发送了这个问题:
Caused by: java.sql.SQLException: The server time zone value 'Jerusalem Daylight Time' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
这是代码:
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/login","root","Password");
System.out.println("Connection: " + con.getCatalog());
谢谢。
在连接 URL :
中指定 MySQL 支持的时区DriverManager.getConnection("jdbc:mysql://localhost:3306/login?serverTimezone=UTC","root","Password");
使用以下命令设置 mysql 服务器时区,时区将根据您所在的地区而定。
设置time_zone='US/Eastern';
或
设置time_zone = '-6:00';
它可能会解决您的问题