第一:IDEA 没有 import 驱动
注册驱动时报错
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
解决:检查lib下的驱动以及是否导入Modules成功
第二:mysql版本不是5.x 而是8.x
error:caching_sha2_password
解决:使用网上下载8.x的驱动点击下载 ,替换现有的lib下的驱动
第三:
java.sql.SQLException: The server time zone value ‘�й���ʱ��’ is unrecognized or represents more than one time zone.
解决:static String url = "jdbc:mysql://localhost:3306/student?serverTimezone=Asia/Shanghai";
在url后面加上时区
第四:
Mysql版本5.x的使用:Class.forName("com.mysql.jdbc.Driver");
Mysql版本8.x的使用:Class.forName("com.mysql.cj.jdbc.Driver");