Type mismatch: cannot convert from ComboPooledDataSource to DataSource

在Eclipse 中使用c3p0数据库资源管理时:

1     private static DataSource dataSource = null;
2     
3     static {
4         dataSource = new ComboPooledDataSource("mvcapp");
5     }

//""内的字符串为:自己在c3p0-config.xml中配置的name
//这里会报错:Type mismatch: cannot convert from ComboPooledDataSource to DataSource
//大致意思就是 new ComboPooledDataSource("") 的返回结果不是 DataSource 的对象
//原因是上面导包出现了问题:import org.apache.tomcat.jdbc.pool.DataSource;(这个包不对)
//正确的包 import javax.sql.DataSource;

原文地址:https://www.cnblogs.com/corvus/p/12432537.html