day3_spring09_spring配置c3p0连接池
1. spring配置c3p0连接池
第一步:导入jar包
第二步 创建spring配置文件,配置连接池
// ComboPooledDataSource dataSource = new ComboPooledDataSource();
// dataSource.setDriverClass("com.mysql.jdbc.Driver");
// dataSource.setJdbcUrl("jdbc:mysql:///spring_day03");
// dataSource.setUser("root");
// dataSource.setPassword("root");
把代码在配置文件中进行配置
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<!-- & 需要转义成 & -->
<property name="jdbcUrl" value="jdbc:mysql://*.*.36.138:3306/spring_day03?userUnicode=true&characterEncoding=utf-8" />
<property name="user" value="root"></property>
<property name="password" value="*"></property>
</bean>