代码改变世界

java mysql连接时出现的问题

2019-03-07 13:57  CCG波克  阅读(351)  评论(0编辑  收藏  举报

当出现Caused by: java.sql.SQLException: Unknown system variable ‘tx_isolation’

一般是mysql-connector-java的版本太低,数据库的版本太高 

之前我用的5.7的数据库,后来换电脑了 装了8.0的数据库,然后mysql-connector-java

 

之后换把mysql-connector-java的版本调高了

需要注意的是

中间又出了这样的错误

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.

需要把com.mysql.jdbc.Driver换成com.mysql.cj.jdbc.Driver

jdbc:mysql://localhost:3306/addict?characterEncoding=utf-8&serverTimezone=GMT