在使用 JDBC 是,常常会出现这个报错
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not allowed
其实这时只需要在 URL 后面加上
&allowPublicKeyRetrieval=true
至于其中的原理嘛,请看这里
点击这里
下面是我的 url
url = jdbc:mysql:///jdbc?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
在使用JDBC连接MySQL时遇到PublicKeyRetrieval异常,通过在URL中添加`&allowPublicKeyRetrieval=true`参数即可解决。此错误表明MySQL不允许自动获取公钥,添加参数后允许该操作,确保了数据库连接的正常建立。
1398

被折叠的 条评论
为什么被折叠?



