用junit对jdbcUtils中getConncetion方法测试时,遇到了两个错误。
-
java.lang.NoClassDefFoundError: com/mchange/v2/cfg/MConfig
解决方式:使用c3p0 0.91之后的版本jar包, 需要额外添加mchange-commons-java-0.2.3.4.jar,我采用的方式是直接将才c3p0换成了 0.91。 -
java.sql.SQLException: Connections could not be acquired from the underlying datab
解决方式:c3p0-config.xml 文件配置有误,检查一下 user password dirverClass jdbcUrl 有没有问题。