出现java.sql.SQLException: No suitable driver的几种解决办法

com.mchange.v2.resourcepool.BasicResourcePool
警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@5df68463 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
java.sql.SQLException: No suitable driver
    at java.sql.DriverManager.getDriver(Unknown Source)
    at
com.mchange.v2.resourcepool.BasicResourcePool
警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@45637a33 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
java.sql.SQLException: Connections could not be acquired from the underlying database!
    at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)

c3p0-config.xml代码:
<? xml version = "1.0" encoding = "UTF-8" ?>
< c3p0-config >
     < default-config >
         < property name = "driverClass" > com.mysql.jdbc.Driver </ property >
         < property name = "jdbcUrl" > jdbc:mysql://localhost:3306/Estore </ property >
         < property name = "user" > estore </ property >
         < property name = "password" > estore </ property >
     </ default-config >
</ c3p0-config >

 原因:(1)很有可能c3p0-config.xml中的配置文件出现问题,比如我是因为把“driverClass”不小心写成了“driver”,
             所以在书写c3p0-config.xml要特别小心,可能多一个空格或者格式稍有问题,都会报以上错误。
             如:驱动类写错、jdbcUrl格式错误等等。
            解决之策:仔细检查书写是否正确!!!
            (2)没有将mysql-connector-java-****-bin.jar包加入到Java运行环境的外部jar包的存放的位置。
              解决之策: 在JAVA_HOME目录下的 jre\lib\ext文件下 (如E:\jdk8\jre\lib\ext)放置一个 连接MySQL数据库的jar包mysql- 
                                connector-java-****-bin.jar
             (3)还有一个也就是字面意思:你没有适用的驱动。
                解决之策:检查是否在WebRoot\WEB-INF\lib目录下是否导入了合适的 mysql-connector-java-****-bin.jar包,没有则导入再重启服务器即可。


如有错误,欢迎指正!谢谢!







  • 10
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值