C3P0 data source configuration throws could not load Driverclass Com.mysql.jdbc.Driver solution

Source: Internet
Author: User

Answer 1:

A driver-class workaround was not found when spring loaded the database connection driver.

com.mchange.v2.c3p0.DriverManagerDataSourceensureDriverLoaded


1, first determine if there is a corresponding driver package

2. See if there are spaces at the end of each line in the metabase connection file.

Answer 2:

C3P0 data source configuration throws could not load Driverclass Com.mysql.jdbc.Driver solution

1.0 Configure the C3P0 data source to always prompt that the database driver cannot be loaded.

But obviously has the drive, very puzzled .....

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

Careful observation, the wood has any problem, he, the tank can also run bastard?

<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}"/>
<!--initialize the number of connections established--
<property name= "Initialpoolsize" value= "ten"/>
<!--maximum idle time, unused connections in 120 seconds are discarded--
<property name= "maxidletime" value= "/>"
<!--when the connection pool is exhausted and the maximum number of connections is not reached, the number of connections fetched at one time-
<property name= "Acquireincrement" value= "2"/>
<!--idle check interval, check the connection pool for idle connections every 120 seconds, in seconds--
<property name= "idleconnectiontestperiod" value= "/>"

</bean>

3.0 views 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

Carefully read, Wood has any problem ah, this he is how the matter ...

Finally, after a multi-party verification, Mactan, originally is the jdbc.properties file jdbc.driverclassname=com.mysql.jdbc.driver, this sentence configuration behind a space ....

The problem is disgusting, the result is very embarrassing ....

C3P0 data source configuration throws could not load Driverclass Com.mysql.jdbc.Driver solution

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.