验证controller层报异常

来源:2-10 验证Controller

appleday

2021-04-07

之前的dao层和service层的junit测试均通过,但是输入localhost:8080/schoolshops/superadmin/listarea出现异常信息

{"errMsg":"org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!\r\n### The error may exist in file [E:\\apache-tomcat-8.5.64\\webapps\\SchoolShops\\WEB-INF\\classes\\mapper\\AreaDao.xml]\r\n### The error may involve com.ahu.schoolshop.dao.AreaDao.queryArea\r\n### The error occurred while executing a query\r\n### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!","succes":false}

我的数据库名称是schoolshops
Jdbc的配置文件内容为
jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/schoolshops?useUnicode=true&characterEncoding=utf8 jdbc.username=root jdbc.password=root

写回答

1回答

翔仔

2021-04-07

同学好,这里是不是用了mysql8 驱动是否已按照升级章节升级了 直接用这里的账号密码连接mysql是否能连上。

0
5
appleday
回复
翔仔
啊,天呀,终于找到错误了,因为jdbc配置里com. MySQL. cj. jdbc. Driver的最后面多了一个空格,导致连接不上数据库,这可真是太坑了
2021-04-10
共5条回复

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5113 学习 · 8144 问题

查看课程