学习慕课上的一个项目,使用的是Spring+Mybatis+c3po 学习搭建框架。
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
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!
The error may exist in file [E:\ecplisepro\schoolShop\target\classes\mapper\AreaDao.xml]
The error may involve com.imooc.o2o.dao.AreaDao.queryArea
The error occurred while executing a query
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!
网上搜了终于找到了答案,mysql-connector-java.jar 我引入 的jar包问题,所以我总结了,在入门学习时大家对版本的要重视,要不然出的错很无厘头,对于刚开始学习的自信心打击很大,我也是卡了好久,才自己解决了这些问题,
于是我果断换回了以前的版本,
修改了POM文件
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.37</version>
</dependency>
JDBC连接Mysql 8.0.12版本的几个注意事项
改了之后通过了单元测试
看见单元测试红色长条变成了绿色,我笑了,虽然很low终究是入门了。