【问题标题】:spring boot application with mysql getting "java.sql.SQLNonTransientConnectionException"带有mysql的spring boot应用程序获取“java.sql.SQLNonTransientConnectionException”
【发布时间】:2016-09-26 07:17:00
【问题描述】:

当我使用 MySQL (5.7.X) 启动 Spring boot(1.3) 应用程序时,在应用程序启动时出现以下异常。任何帮助将不胜感激

驱动程序管理连接不正确的状态并失败

java.sql.SQLNonTransientConnectionException: Public Key Retrieval

【问题讨论】:

  • 你能发布你的代码和课程吗?

标签: java mysql spring-boot


【解决方案1】:

您应该将客户端选项添加到您的 mysql-connector allowPublicKeyRetrieval=true 例如。

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

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

【讨论】:

    【解决方案2】:

    我能够弄清楚这一点,这是由于我在mysql 中配置用户权限的方式。我使用的身份验证方法为SHA256,当我将其更改为normal 时,它开始工作。请查看此url 了解更多详情。

    【讨论】:

      【解决方案3】:

      就我而言,我在 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
      

      更改第二行后:

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

      【讨论】:

      • 你改的second line是什么?
      猜你喜欢
      • 1970-01-01
      • 2016-08-07
      • 2018-12-05
      • 2015-03-28
      • 1970-01-01
      • 2019-07-29
      • 2019-08-12
      • 2016-06-13
      • 2016-04-08
      相关资源
      最近更新 更多