eclipse java连接mysql8.0遇到的JDK版本驱动时间相关报错及解决方法

1、JDK版本报错:
UnsupportedClassVersionError: com/mysql/cj/jdbc/Driver : Unsupported major.minor version 52.0
解决办法:jdk版本要改为jdk1.8,jdk版本和Java编译器内部的版本号对应关系:
J2SE 8 = 52,
J2SE 7 = 51,
J2SE 6.0 = 50,
J2SE 5.0 = 49,
2、驱动相关报错:
Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver’. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
解决方法:应该用com.mysql.cj.jdbc.Driver,而不是com.mysql.jdbc.Driver
3、时间相关报错:
he 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.
解决方法(spring是我本地的测试库):
应该用jdbc:mysql://localhost:3306/spring?&useSSL=false&serverTimezone=UTC,加上了***?&useSSL=false&serverTimezone=UTC***
而非
jdbc:mysql://localhost:3306/spring
4、注意:还需要用mysql-connector-java-8.0.19.jar这个包,而非老版本的包

猜你喜欢

转载自blog.csdn.net/u010425839/article/details/115220888