6/8

清荣峻茂發表於2024-06-08

java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

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 com/itheima/mapper/BrandMapper.java (best guess)
### The error may involve com.itheima.mapper.BrandMapper.selectAll
### The error occurred while executing a query
### Cause: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
	org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
	org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)
	org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
	org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147)
	org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80)
	org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:152)
	org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85)
	jdk.proxy4/jdk.proxy4.$Proxy31.selectAll(Unknown Source)
	com.itheima.service.impl.BrandServiceImpl.selectAll(BrandServiceImpl.java:25)
	com.itheima.web.select.SelectAllServlet.doGet(SelectAllServlet.java:22)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)

原因:顯而易見的是,你資料庫的使用者名稱和密碼錯誤,修改一下mybatis-config.xml檔案就可以了

相關文章