使用SHA256验证MySQL spring数据源连接

时间:2017-07-16 09:18:11

标签: java mysql spring

我有一个连接到MySQL数据库的spring数据源连接

<bean id="sceLocationsDataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://IP:PORT/SCHEMA" />
        <property name="username" value="user" />
        <property name="password" value="my_password_goes_here" />

    </bean>

当我尝试连接时,我得到以下异常

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not allowed
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
    at com.mysql.jdbc.Util.getInstance(Util.java:383)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1023)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:997)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:983)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:928)
    at com.mysql.jdbc.authentication.Sha256PasswordPlugin.nextAuthenticationStep(Sha256PasswordPlugin.java:108)
    at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1791)

似乎也是这个问题在here

知道

我的问题是如何将SHA256身份验证添加到spring数据源配置?

0 个答案:

没有答案