eclipse连接数据库时本人出现的一些报错问题汇总

原创
2021/10/18 16:20
阅读数 112

我在连接数据库查找某一个表内容时出现以下错误:

错误一:

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
### The error may exist in sqlmapper/userdao.xml
### The error may involve usercqy.selUserById
### The error occurred while executing a query
### Cause: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

该内容报错解析:Access denied for user 'root'@'localhost' (using password: YES)使用密码正确,但是拒绝访问

我找了很久的原因,也重启了mysql服务器,最后发现是在mybat_config.xml文件中出现了错误

同时在jdbc.properties文件中发现,两者密码的标签不一样,没想到是这么个致命又小儿科的错

解决方案则是:统一“密码”的标签,都改为password或者upassw,报错就消失了!

错误二:

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error building SqlSession.
### The error may exist in sqlmapper/userdao.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'sqlmapper/userdao.xml'. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.tky.mybatis_commend03.POJO.UserPOJO.java'.  Cause: java.lang.ClassNotFoundException: Cannot find class: com.tky.mybatis_commend03.POJO.UserPOJO.java

错误分析:错误出现在sqlmapper/userdao.xml文件中

经过排查发现:

后缀名多了个java字样导致无法识别

修改过后

除掉java后缀,便排除了报错

(后续出现错误会继续编辑)

 

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部