在使用 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