【发布时间】:2020-01-28 14:26:35
【问题描述】:
package com.practise;
import java.sql.*;
public class connectSQL {
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/test", "root", "Root!123321");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from testTable");
while(rs.next()){
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));
con.close();
}
}catch(Exception e){
System.out.println("We got an exception...");
System.out.println(e.getMessage());
}
}
}
输出:
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
We got an exception...
The server time zone value 'EEST' 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.
【问题讨论】:
-
您是否尝试过加载“com.mysql.cj.jdbc.Driver”或删除您正在加载驱动程序的那一行?似乎它希望您执行的操作是因为您选择的驱动程序不再受支持。
-
如果该警告不是您尝试连接时发生的异常,请发布异常。
-
msql jdbc驱动版本是多少?