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

Posted 哆啦任意门

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了出现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目录下的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的几种解决办法的主要内容,如果未能解决你的问题,请参考以下文章

java.sql.SQLException: ORA-00604: 递归 SQL 级别 1 出现错误 ORA-01003: 语句未进行语法分析

hibernate 出现Caused by: java.sql.SQLException: Column 'id' not found.异常

在使用JDBC连接数据库是出现java.sql.SQLException: No value specified for parameter 1

Tomcat启动时出现java.sql.SQLException

java连接Oracle数据库,从ResultSet中提取数据出现java.sql.sqlException结果集已耗尽

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