idea连接MySQL报错Could not create connection to database server. Attempted reconnect 3 times. Giving up.
程序员文章站
2022-05-01 15:54:32
...
Could not create connection to database server. Attempted reconnect 3 times. Giving up.
问题描述
在idea中使用jdbc连接mysql,测试连接时连接成功可是程序运行时数据库连接不上。
问题原因
mysql的jar包不合适。
解决方法
把mysql驱动的版本改成测试连接时的jar包版本。
mysql5.7.29版本对应的驱动jar包是8.0.21(5.1.47~5.1.49都运行不出来。)
注意
MySQL8.0在连接时的配置
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/你使用的数据库名字?useSSL=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT"/>
上一篇: Connection to @localhost failed. [08001] Could not create connection to database server. Attempt
推荐阅读
-
pycharm连接mysql是出现Connection to orm02@127.0.0.1 failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
-
[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
-
Could not create connection to database server. Attempted reconnect 3 times. Giving up.
-
idea连接MySQL报错Could not create connection to database server. Attempted reconnect 3 times. Giving up.
-
[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
-
pycharm连接mysql是出现Connection to orm02@127.0.0.1 failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
-
[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.