Local environment -Database: MySQL 8.0.16 ・ Language: Java -JDBC driver: mysql-connector-java-8.0.16 -DB reference tool: DBeaver
When I tried to connect to DB from Java, it suddenly stopped working. The following error description is on the eclipse console.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet successfully received from the server was 25 milliseconds ago.
The last packet sent successfully to the server was 28 milliseconds ago.
When I try to connect from DBeaver, the following error description appears.
SQL Error [08001]: Public Key Retrieval is not allowed
I searched and saw the following article and was able to solve it. https://stackoverflow.com/questions/50379839/connection-java-mysql-public-key-retrieval-is-not-allowed
DBeaver:
Java code:
sample.java
String database = "jdbc:mysql://localhost:3306/sample_db?allowPublicKeyRetrieval=true&useSSL=false";
Recommended Posts