java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(DriverManager.java:31

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值