有关C3p0数据连接问题,出现错误?
在eclipse中连接C3p0。使用的MySQL数据库。c3p0已配置。导入的Jar包:c3p0-0.9.5.1.jar mysql-connector-java-5.1.36-bin.jar mchange-commons-java-0.2.3.1.jar
public class JdbcUtils {
private static DataSource dataSource=null;
static{
dataSource= new ComboPooledDataSource("mvcapp");
}
public static Connection getConnection() throws SQLException{
return dataSource.getConnection();
}
}
测试:
@Test
public void testGetConnection() throws SQLException {
Connection connection=JdbcUtils.getConnection();
System.out.println(connection);
}
出现如下错误:java.lang.NoClassDefFoundError: com/mchange/v2/cfg/MConfig
at com.mchange.v2.c3p0.cfg.C3P0Config.findLibraryMultiPropertiesConfig(C3P0Config.java:157)
at com.mchange.v2.c3p0.cfg.C3P0Config.<clinit>(C3P0Config.java:143)
at com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase.<init>(PoolBackedDataSourceBase.java:54)...
Caused by: java.lang.ClassNotFoundException: com.mchange.v2.cfg.MConfig
at (Unknown Source)...