Database error: Cause com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure (resolved)

reason

1. Because of SSL connection (most people’s reasons)

Because MySQL needs to indicate whether to perform an SSL connection in higher versions. It is possible that the MySQL dependency version introduced by your pom file is MySQL5.7 and above . In these cases, you need to specify the SSL connection. If you don't know, it is enabled by default, so the above error will occur.

2. Because of database connection timeout

When the database is restarted or the database idle connection exceeds the set maximum timemout, the database will forcibly disconnect the existing connection.

Note: If the following error occurs, you can also try the solution to this error.
No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

solve

1. Just set useSSL=false to disable SSL

例如:jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false

SSL function

In versions before MySQL 5.7, security was low and any user could connect to the database. Therefore, the official increased privacy protection in version 5.7. And the default useSSL = true value is adopted to prevent arbitrary modification of the database. In version 8.0, SSL is still retained, and the default value is true.

2. Timeout resolution

ⅠConfigure the interactive_timeout=388000 and wait_timeout=388000windows系统 attributes of the MySQL my.inifile .

Under system II linux, you need to go to the installation directory of mysql to view the my.cnf file, and then modify the same attributes.

おすすめ

転載: blog.csdn.net/twotwo22222/article/details/128616885