报错信息:
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 com/shiyaxin/dao/IAccountDao.java (best guess)
### The error may involve com.shiyaxin.dao.IAccountDao.findAll
原因:org.springframework.jdbc。获取JDBC连接失败;嵌套异常是java.sql。无法从基础数据库获取连接!
###错误可能存在于com/shiyaxin/dao/IAccountDao.java(最佳猜测)
错误可能涉及com.shiyaxin.dao.IAccountDao.findAll
分析到错误的代码处:
注意url和driver里面的/和:,不要多了,或者少了,我的错误是多了一个/
<!--Spring整合MyBatis对象-->
<!-- 配置连接池 c3p0的写法,跟POOLED属性名不一样的-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/ssm"></property>
<property name="user" value="root"></property>
<property name="password" value="123456"></property>
</bean>
<!-- 配置SqlSessionFactory工厂-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
</bean>