mybatis整合springmvc报数据库连接错误求解

oot cause

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))

The error may exist in cn/itcast/ssm/mapper/ItemsMapperCustom.xml

The error may involve cn.itcast.ssm.mapper.ItemsMapperCustom.findItemsList

The error occurred while executing a query

Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))

org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)

2个回答

工程代码放在在虚拟机win10下跑没有问题,在我本机上一直报这个错误,数据库服务器连接的都是一样的地址

怀疑你localhost的密码只支持自己连接,有可能不识别或者未授权,根据错误来看是不允许,所以你可以试着吧root@localhost:改为你数据库所在的ip地址,或者用其他用户来连接试一试;
尽量不要用localhost来映射数据库连接,而用固定ip地址来代替。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问