c3p0连接数据库报错

Posted 1314520o

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c3p0连接数据库报错相关的知识,希望对你有一定的参考价值。

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector
    at cn.itcast.jdbc.JdbcUtils.<clinit>(JdbcUtils.java:17)
    at dao.DataBase1.<init>(DataBase1.java:18)
    at service.Service.<init>(Service.java:9)
    at UI.Welcome.<init>(Welcome.java:23)
    at UI.Welcome$1.run(Welcome.java:39)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.mchange.v2.ser.Indirector
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 19 more

导入外包的文件夹要建在项目下,不要建在src下,这个错误是因为导入的jar包导错了,找不到来源,连接不上数据库。

技术图片

这里没有导到mchange-commons-0.2.jar这个包,加了这个包之后就好了。

以上是关于c3p0连接数据库报错的主要内容,如果未能解决你的问题,请参考以下文章

javaweb c3p0连接oracle12c

使用c3p0与DBCP连接池,造成的MySql 8小时问题解决方式

C3P0连接池操作数据库

C3P0连接池的使用

C3P0连接池的使用

数据库连接池c3p0