2020-10-29

[Solved] Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure

 

Googled: "spring.datasource.url" "Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure" "Caused by: java.net.ConnectException: Connection refused: connect"

But has no solutions.

Situation was: SpringBoot Microservice failed to launch due to error above.

MySql version was 8.0.22


Found that my repository was develop on MySql version 8.0.15


After revert back to MySql version 8.0.15, no more Communications link failure error.






But hit another issue 

mysql 8.0.15 "java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed"


Need to revise spring.datasource.url by append database connection string

&allowPublicKeyRetrieval=true


Then service is up.