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


    今天在用C3p0连接MySql数据库 这个时候出现了上面的错误,

    一般来说这种错误有3个方向解决 一般都是db的配置的问题 ,一定要小心DB 的配置

    八月 19, 2017 8:30:46 下午 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask run
    警告: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@2b8dab95 -- 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.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:223)
     at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
     at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
     at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
     at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
     at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
     at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)

    1.:(1)很有可能c3p0-config.xml中的配置文件出现问题

    这些配置一定要配置正确,像  第一个图片就忘记了一个“冒号“

    2) 将Jar包放入Java lib目录

    在JAVA_HOME目录下的jrelibext文件下(如E:jdk8jrelibext)放置一个连接MySQL数据库的jar包mysql- connector-java-****-bin.jar

    3)Jar 包没有加入到Buildpath

    看jar包是否在Referenced Libraries 里

  • 相关阅读:
    全网最详细的Linux命令系列-ls命令
    Kubernetes 部署策略详解-转载学习
    Kubernetes工作流程--<1>
    详解CURL状态码,最全的代码列表
    Haproxy-4层和7层代理负载实战
    Keepalived+Nginx高可用实例
    实现FTP+PAM+MySQL环境,批量配置虚拟用户
    每秒处理10万订单乐视集团支付Mysql架构-转载
    构建 CDN 分发网络架构简析
    Linux系统入门简介<1>
  • 原文地址:https://www.cnblogs.com/mythdoraemon/p/7397839.html
Copyright © 2020-2023  润新知