2

When I start Spring boot(1.3) application with MySQL (5.7.X), I get the below exception on application startup. Any help would be much appreciated

The driver manages the state of connecting improperly and fails with

java.sql.SQLNonTransientConnectionException: Public Key Retrieval

1
  • Can you post your code and classes? Commented May 27, 2016 at 23:41

3 Answers 3

3

You should add client option to your mysql-connector allowPublicKeyRetrieval=true eg.

spring.datasource.url=jdbc:mysql://localhost:3306/ponto_inteligente?allowPublicKeyRetrieval=true

https://mysql-net.github.io/MySqlConnector/connection-options/

Sign up to request clarification or add additional context in comments.

Comments

2

I was able to figure this out, and it was due to the way I configured the user privileges in mysql. I was using the authentication method as SHA256 and when I changed it to normal, it started working. Please check this url for more detail.

Comments

-1

In my case, I was using the following block in application.properties:

#MySql
spring.jpa.hibernate.ddl-auto=none
*spring.datasource.url=jdbc:mysql://localhost:3306/ponto_inteligente? 
                         verifyServerCertificate=false&
                         autoReconnect=true&
                         useSSL=false*
spring.datasource.name=USER_LOGIN
spring.datasource.password=USER_PASSWORD

# exibe comandos SQL
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.use_sql_comments=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.type=trace

After changing the second line worked:

*spring.datasource.url=jdbc:mysql://localhost:3306/ponto_inteligente? 
                         verifyServerCertificate=false&
                         autoReconnect=true&
                         useSSL=false&
                         user=USER_LOGIN&
                         password=USER_PASSWORD*

1 Comment

What is the second line you changed?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.