Exception in thread "main" java.sql.SQLException: The server time zone value '�й���ʱ��' 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.
数据库名后面加
解决了 。。。。。。。。。。。。。。。。用时两个小时我真的会谢
package com.zhang;
import javax.xml.transform.Result;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class JDBCDemo {
public static void main(String[] args) throws Exception {
// Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/t?useSSL=false&serverTimezone=Hongkong", "root", "123456");
Statement stat = conn.createStatement();
String sql = "SELECT *FROM us";
ResultSet rs = stat.executeQuery(sql);
while (rs.next()) {
System.out.println(rs.getInt("pass"));
}
conn.close();
stat.close();
conn.close();
}
}