c3p0数据源配置抛出Could not load driverClass com.mysql.jdbc.Driver的解决方案
Posted charles999
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c3p0数据源配置抛出Could not load driverClass com.mysql.jdbc.Driver的解决方案相关的知识,希望对你有一定的参考价值。
回答1:
spring 加载数据库连接驱动的时候出现找不到驱动类解决办法。
com.mchange.v2.c3p0.DriverManagerDataSourceensureDriverLoaded
1, 首先确定是否有相应的驱动包
2, 查看配置数据库连接文件每行的末尾是否有空格。
回答2:
1.0 配置c3p0数据源,一直提示 无法加载数据库驱动。
但是明明有驱动,非常疑惑。。。。。
com.mchange.v2.c3p0.DriverManagerDataSource ---- Could not load driverClass com.mysql.jdbc.Driver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1311)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1145)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.mchange.v2.c3p0.DriverManagerDataSource.ensureDriverLoaded(DriverManagerDataSource.java:112)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:144)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)
at
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
at
com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
com.mchange.v2.c3p0.DriverManagerDataSource ---- Could not load driverClass com.mysql.jdbc.Driver
仔细观察,木有任何问题,他么的 ,水缸里还能把王八跑了?
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<!-- 初始化建立的连接数 -->
<property name="initialPoolSize" value="10"/>
<!-- 最大空闲时间,120秒内未被使用的连接将被丢弃 -->
<property name="maxIdleTime" value="120"/>
<!-- 当连接池耗尽,且未达到最大连接数时,一次获取的连接数 -->
<property name="acquireIncrement" value="2"/>
<!-- 空闲检查时间间隔, 每隔120秒检查连接池里的空闲连接 ,单位是秒 -->
<property name="idleConnectionTestPeriod" value="60"/>
</bean>
3.0查看jdbc.properties
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc\:mysql\://localhost\:3306/dftsms?useUnicode\=true&characterEncoding\=UTF8
jdbc.username=root
jdbc.password=1234
jdbc.initialPoolSize=10
jdbc.maxIdleTime=120
jdbc.acquireIncrement=2
jdbc.idleConnectionTestPeriod=60
仔仔细细看完,木有任何问题啊 ,这他么怎么回事儿。。。。。。
最后,经过多方查证,马丹,原来是jdbc.properties 文件中jdbc.driverClassName=com.mysql.jdbc.Driver,这一句配置 后面有个空格。。。。。。。
问题很恶心,结果很尴尬。。。。
以上是关于c3p0数据源配置抛出Could not load driverClass com.mysql.jdbc.Driver的解决方案的主要内容,如果未能解决你的问题,请参考以下文章
c3p0 空指针异常 com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acqu
网站部署后Parser Error Message: Could not load type 的解决方案
Could not find or load main class Hello
keil4调试时出错 could not load file'***.AXF'. Debugger aborted!
SQLyog | 连接数据库报错plugin caching_sha2_password could not be loaded
SQLyog连接数据库 提示错误plugin caching_sha2_password could not be loaded