继上一篇,因为里面用到Druid,导致了数据库连不上,其实是不对,是版本不统一

因为将mysql-connector 8.0.6改成了5.1.49,导致druid1.1.6.jar对应的mysql-connector不存在了,

这个druid1.1.6.jar,对应的是

Druid对应mysql-connector版本

 

所以当然连不上5.7的数据库了。

 

那么这个要如何去看呢?

1、随便点一个版本

 

 

Druid对应mysql-connector版本

 

 2、拉到最下面,看一下

Druid对应mysql-connector版本

mysql-connector5.1.49之前不存在cj包。

在mysql-connector6及以后的话,就有了。

Druid对应mysql-connector版本

 

 这个包也可以连接mysql5.7等版本,不过,需要在连接的sql上加上serverTimezone=UTC

jdbc:mysql://localhost:3306/dbName?serverTimezone=UTC&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8

 

相关文章:

  • 2023-02-27
  • 2022-12-23
  • 2022-02-10
  • 2021-09-27
  • 2021-11-01
  • 2021-04-04
  • 2021-11-20
  • 2022-02-23
猜你喜欢
  • 2022-01-09
  • 2022-12-23
  • 2021-10-18
  • 2021-12-31
  • 2021-06-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案