【Java】Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'.

用JDK9玩Jdbc连接Mysql时,报如下错误信息

解决方案:提示信息表明数据库驱动com.mysql.jdbc.Driver已经被弃用了,应当使用新的驱动com.mysql.cj.jdbc.Driver

所以,按照提示更改jdbc.properties配置 com.mysql.jdbc.Driver  改为 com.mysql.cj.jdbc.Driver

jdbc.driver=com.mysql.cj.jdbc.Driver

改完后,发现还是报错,报错信息如下

com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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.

解决方案: 这是由于数据库和系统时区差异所造成的,应在jdbc连接的url后面加上serverTimezone=GMT即可解决问题

test.jdbc.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false&tinyInt1isBit=false&serverTimezone=GMT

  

 

posted @ 2019-05-23 17:21  yangyh11  阅读(290)  评论(0编辑  收藏  举报