Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed ### The error may exist in mysql/user/mappers/usermapper.xml ### The error may involve mysql.user.mappers.usermapper.selectAll ### The error occurred while executing a query ### Cause: java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80) at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:152) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85) at com.sun.proxy.$Proxy4.selectAll(Unknown Source) at org.example.main2.main(main2.java:25) Caused by: java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:829) at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:449) at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:242) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) at java.sql.DriverManager.getConnection(Driv
时间: 2023-11-09 10:04:31 浏览: 283
Node.js API详解之 util模块用法实例分析
这个问题是因为你正在使用过时的MySQL驱动程序。新的驱动程序类是`com.mysql.cj.jdbc.Driver`。新的驱动程序类会自动通过SPI进行注册,不需要手动加载驱动程序类。此外,你遇到的错误是“Public Key Retrieval is not allowed”,这可能是由于MySQL连接配置的问题引起的。你可以尝试在连接URL中添加`allowPublicKeyRetrieval=true`来解决此问题。例如:
```java
String url = "jdbc:mysql://localhost:3306/database?allowPublicKeyRetrieval=true";
```
请确保将`localhost:3306`替换为您的MySQL服务器主机和端口,`database`替换为您要连接的数据库名称。
阅读全文