一、spring配置c3p0连接池
1、导入spring、c3p0的jar包以及MySQL驱动
2、将链接池所用的属性抽象到db.properties文件中
jdbc.user=root
jdbc.password=root
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.jdbcUrl=jdbc:mysql:///spring
jdbc.initPoolSize=5
jdbc.maxPoolSize=10
3、在spring配置文件中配置连接池
class="com.mchange.v2.c3p0.ComboPooledDataSource">
4、测试
@Test
public void testDataSource() throws SQLException {
DataSource dataSource =ctx.getBean(DataSource.class);
System.out.println(dataSource.getConnection());
}