spring 整合c3p0连接池
Posted 帅的土掉渣
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring 整合c3p0连接池相关的知识,希望对你有一定的参考价值。
<!--pom.xml引入jar包-->
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.5</version>
</dependency>
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <context:property-placeholder location="classpath:db.properties"/> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driver}"/> <property name="jdbcUrl" value="${jdbc.jdbcUrl}"/> <property name="user" value="${jdbc.user}"/> <property name="password" value="${jdbc.password}"/> <property name="initialPoolSize" value="1" /> <property name="minPoolSize" value="0" /> <property name="maxPoolSize" value="10" /> <property name="acquireIncrement" value="5" /> <property name="maxIdleTime" value="10" /> <property name="maxStatements" value="0" /> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="mapperLocations" value="classpath:com/kuang/mapper/*.xml"/> <property name="typeAliases" value="com.kuang.pojo.User"/> </bean> <bean id="userMapper" class="com.kuang.mapper.UserMapperImpl"> <property name="sqlSessionFactory" ref="sqlSessionFactory"/> </bean> </beans>
以上是关于spring 整合c3p0连接池的主要内容,如果未能解决你的问题,请参考以下文章
JavaEE基础(06):Servlet整合C3P0数据库连接池