MySQL8.0以上的JDBC驱动的一些小的问题
-
是使用
Class.forName("com.mysql.cj.jdbc.Driver");而不是Class.forName("com.mysql.jdbc.Driver");与之前加载驱动的形式不同了通过java.sql.Driver文件查看加载驱动时的类是什么
-
出现
[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]类似的报错时,查看是中文乱码还是时间问题- 解决时间的报错
jdbc:mysql://localhost:3306/test?serverTimezone=UTC - 解决中文乱码的问题
jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8 - 同时解决两个问题
jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
- 解决时间的报错