出現java.sql.SQLException: No suitable driver的幾種解決辦法

來源:互聯網
上載者:User

標籤:解決辦法   manage   number   lex   uil   strong   exce   沒有   com   

今天在用C3p0串連MySql資料庫 這個時候出現了上面的錯誤,

一般來說這種錯誤有3個方向解決 一般都是db的配置的問題 ,一定要小心DB 的配置

八月 19, 2017 8:30:46 下午 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask run
警告: [email protected]95 -- 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目錄下的jre\lib\ext檔案下(如E:\jdk8\jre\lib\ext)放置一個串連MySQL資料庫的jar包mysql- connector-java-****-bin.jar

3)Jar 包沒有加入到Buildpath

看jar包是否在Referenced Libraries 裡

 

出現java.sql.SQLException: No suitable driver的幾種解決辦法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.