c3p0数据源配置抛出Could not load driverClass com.mysql.jdbc.Driver的解决方案

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 


查看applicationcontext.xml

仔细观察,木有任何问题


    
   
   
   
   
 
       

       
   
       
   
       
    
    


查看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,这一句配置 后面有个空格。。。。。。。



你可能感兴趣的:(java常见错误)