mysql-connector-java版本匹配问题ERROR DruidDataSource - create connection SQLException

装新环境mysql使用的5.8版本,启动项目后发现报错连接不上数据库

Druid-ConnectionPool-Create-150783284] ERROR DruidDataSource - create connection SQLException, url: jdbc:mysql://localhost:3306/db_plat?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false, errorCode 0, state 08001
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.

研究一下发现是因为低版本的mysql-connector-java和高版本的mysql不匹配,升级mysql-connector-java版本后问题解决,如下:

<dependency>
	<groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.46</version>
</dependency>

你可能感兴趣的:(后端)