close

[Solved] Exception in thread “main” java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to connect Mysql database with Java But I am facing following error Exception in thread “main” java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How This Error Occurs ?

I am trying to connect Mysql database with Java But I am facing following 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

How To Solve Exception in thread “main” java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at Error ?

  1. How To Solve Exception in thread “main” java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at Error ?

    To Solve Exception in thread “main” java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at Error Just need to add client option to your mysql-connector allowPublicKeyRetrieval=true to allow the client to automatically request the public key from the server. and Also add useSSL=false. Just like this Example. jdbc:mysql://localhost:3306/db?allowPublicKeyRetrieval=true&useSSL=false. Now your error must be solved.

  2. Exception in thread “main” java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at

    To Solve Exception in thread “main” java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at Error Just need to add client option to your mysql-connector allowPublicKeyRetrieval=true to allow the client to automatically request the public key from the server. and Also add useSSL=false. Just like this Example. jdbc:mysql://localhost:3306/db?allowPublicKeyRetrieval=true&useSSL=false. Now your error must be solved.

Solution 1: Set allowPublicKeyRetrieval to true

Just need to add client option to your mysql-connector allowPublicKeyRetrieval=true to allow the client to automatically request the public key from the server. and Also add useSSL=false. Just like this Example.

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

Now your error must be solved.

Solution 2: Using DBeaver

If You are using DBeaver then just follow this setting.

  1. First of all Right click on your connection
  2. and choose “Edit Connection”
  3. On the “Connection settings” screen (main screen) click on “Edit Driver Settings”
  4. Click on “Connection properties”
  5. Right click the “user properties” area
  6. and choose “Add new property”
  7. Add two properties: “useSSL” and “allowPublicKeyRetrieval
  8. Set their values to “false” and “true” by double clicking on the “value” column

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Please Rate Our Solution to Motivate Us For Give Our Best

Leave a Comment