java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:315)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:240)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)
at
开始系统检查代码;
1. 首先运行数据库的到达数据表写作了。@Override
public void out(String outUser, int money) {
String sql = "update accounts set money=money-? where name=?";
this.jdbcTemplate.update(sql, money,outUser);
}修改后无果
2、将jar包都换成书上的,原本jar包
aspectjweaver-1.6.8.jar
c3p0-0.9.2.1.jar
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.aspectj.weaver-1.6.4.RELEASE.jar
commons-logging-1.1.1.jar
mchange-commons-java-0.2.3.4.jar
mysql-connector-java-5.1.46-bin.jar
spring-aop-4.2.4.RELEASE.jar
spring-aspects-4.0.0.RELEASE.jar
spring-beans-4.3.22.RELEASE.jar
spring-context-4.3.22.RELEASE.jar
spring-core-4.3.22.RELEASE.jar
spring-expression-4.3.22.RELEASE.jar
spring-jdbc-4.0.0.RELEASE.jar
spring-tx-4.0.0.RELEASE.jar
替换后:
aspectjweaver-1.6.8.jar
c3p0-0.9.2.1.jar
com.springsource.com.mchange.v2.c3p0-0.9.1.2.jar
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.apache.commons.logging-1.1.1.jar
com.springsource.org.aspectj.weaver-1.6.4.RELEASE.jar
commons-logging-1.1.1.jar
mchange-commons-java-0.2.3.4.jar
mysql-connector-java-5.1.46-bin.jar
spring-aop-4.2.4.RELEASE.jar
spring-aspects-4.0.0.RELEASE.jar
spring-beans-4.3.22.RELEASE.jar
spring-context-4.3.22.RELEASE.jar
spring-core-4.3.22.RELEASE.jar
spring-expression-4.3.22.RELEASE.jar
spring-jdbc-4.0.0.RELEASE.jar
spring-test-4.0.4.RELEASE.jar
spring-tx-4.0.0.RELEASE.jar
运行失败
只能先把配置写死,运行ok,资源文件也就没什么用了
<!-- 加入资源文件 -->
<context:property-placeholder location="classpath*:db.properties" ignore-unresolvable="true"/>
<!-- 配置数据源 ,读取db.properties文件-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="root"></property>
<property name="password" value="123456"></property>
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql:///spring"></property>
</bean>