报错:MySQLNonTransientConnectionException

错误信息:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

com.mysql.jdbc.exceptions.jdbc4。MySQLNonTransientConnectionException:无法创建到数据库服务器的连接。尝试重新连接3次。放弃。
引起的:com.mysql.jdbc.exceptions.jdbc4。通信例外:通信链接失败


The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
最后一个成功发送到服务器的数据包是在0毫秒之前。驱动程序没有从服务器收到任何数据包。


Caused by: java.net.ConnectException: Connection timed out: connect
由:java.net.ConnectException: Connection超时:connect引起


Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@645fadf4]
关闭非事务SqlSession[org.apache.ibatis.session.defaults.DefaultSqlSession@645fadf4]


java.net.ConnectException: Connection timed out: connect
java.net.ConnectException: 连接超时:connect


启动服务器正常,然后访问网页后报错。反正就是数据库连不上。但是Navicat里完全没问题,反正搞了好久,什么都检查了一边,吐了。

解决:

结果第二天发现配置的IP写错了= =

# mysql数据库连接信息
spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.datasource.url = jdbc:mysql://172.xx.xxx.x:3306/jh4j_test?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&failOverReadOnly=false
spring.datasource.username = root
spring.datasource.password = root

改完就能访问了。

你可能感兴趣的:(报错:MySQLNonTransientConnectionException)