How Can We Address This Issue “Exception in thread “main” java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at”?

Java is a modern, high-level, object-oriented, secure, and powerful programming language and is a Platform. The Java programming language was originally developed by Sun Microsystems, initiated by James Gosling, and released in 1995.

When you run the project with Java, you will see the message “Exception in thread “main” java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at“.

This software mistake has been so common that it could occur to anyone. As a result, how did it happen, and can it be solved? Let’s discover together to find out the best methods for this issue.

Reason For The Error: “Exception in thread “main” java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at”

When you are connecting the Mysql database, you face this error.

Exception in thread “main” java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at
com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:108) at

The Top Solution

Approach 1

You can add the allowPublicKeyRetrieval=true client option to your mysql-connector to enable the company to instantly ask the public key out from the server. Also, you should include useSSL=false like in this example.

jdbc:mysql://localhost:3306/db?allowPublicKeyRetrieval=true&useSSL=false
Approach 2

If you’re using DBeaver, you can use this setting.

  • Initially, right-click on the connection and select “Edit Connection.”
  • Select “Edit Driver Settings” here on the “Connection Settings” display (main screen).
  • Select “Connection Properties” from the menu.
  • Right-click a “user properties” section and select “Add new property.”
  • Add the following two properties: “useSSL” and “allowPublicKeyRetrieval.”
  • By double-clicking here on the “value” column, you can change their value systems to “false” and “true.”

Conclusion

Java is a powerful object-oriented programming language and one of today’s most widely used platforms. Some of the games, applications, and software on both computers and phones are created by Java.

If the failure “Exception in thread “main” java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at” persists, follow the steps below to resolve it.

When you need support or have basic Java questions, a large team of studies is always ready to aid. At last, we desire all subscribers a wonderful day full of new ideas.

Scroll to Top