zoukankan      html  css  js  c++  java
  • mybatis或hibernate框架连接数据库报错:java.sql.SQLException: No suitable driver或No suitable driver found for http://maven.apache.org

    报错:

    java.sql.SQLException: No suitable driver或No suitable driver found for http://maven.apache.org 

    报错详情:

    十二月 09, 2020 5:30:32 下午 com.mchange.v2.resourcepool.BasicResourcePool 
    警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@a91ff6 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
    十二月 09, 2020 5:30:32 下午 com.mchange.v2.resourcepool.BasicResourcePool 
    警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@692194a7 -- 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(DriverManager.java:315)
        at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:285)
        at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
        at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
        at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
        at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
        at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)

    初学mybatis遇到的一个问题将mybatis-config.xml里的连接数据库的4个基本信息
    抽出了单独放在一个properties里时,再测试方法,爆出该错误

    解决办法:

    将db.properties的url改为urlName(只要是非url均可),mybatis的设置xml的url对于的value也别忘记了改名!

    原因:

    之前db.properties里的url=xxx和
    pom.xml里的url:http://maven.apache.org撞车了,数据库配置文件的url被替换了!
    下图:pom.xml的url

    解决:

    把配置文件key改下名字就可以,比如加前缀jdbc.xxx

    转 : https://blog.csdn.net/qq_44831907/article/details/107319521

    参考: https://blog.csdn.net/qq_36534731/article/details/102628578

  • 相关阅读:
    Codeforces 791B. Bear and Friendship Condition 联通快 完全图
    SHU oj 422 风力观测 线段树
    hdu 5833 Zhu and 772002 高斯消元
    Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) E. Cards Sorting 树状数组
    Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) D. Office Keys time limit per test2 seconds 二分
    Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) E. DNA Evolution 树状数组
    Educational Codeforces Round 25 E. Minimal Labels 拓扑排序+逆向建图
    hdu 3864 D_num Pollard_rho算法和Miller_Rabin算法
    hdu 3861 The King’s Problem trajan缩点+二分图匹配
    Codeforces Round #420 (Div. 2) E. Okabe and El Psy Kongroo 矩阵快速幂优化dp
  • 原文地址:https://www.cnblogs.com/fps2tao/p/14109969.html
Copyright © 2011-2022 走看看