Mysql连接出现的问题

114 阅读1分钟

1。# com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException 我遇到的是mysql驱动版本问题:我的mysql版本为8.0.11,但项目中用到的mysql驱动包的版本为5.1.46,版本不匹配。所以会导致这个问题。把mysql驱动包的版本改为8+就行,我改为8.0.11.此问题不再出现。 2.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. 这个问题是mysql驱动包版本遗留问题,老版本用com.mysql.jdbc.Driver,新版本用com.mysql.cj.jdbc.Driver.可以不用管,这个驱动是通过Spring的SPI自动注入的,也可以在配置文件中显示的将driver加进去。 3.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. 这个是时区的问题,需要指定时区。serverTimezone=UTC,我也不知道为什么要这样,反正指定时区后,问题解决,