|
楼主 |
发表于 2015-10-13 09:43:30
|
显示全部楼层
c3p0、dbcp数据源在spring的配置
?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
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-3.0.xsd">
<!-- 配置数据源的位置 dbcp.properties -->
<context:property-placeholder location="classpath:dbcp.properties"/>
<!-- 配置数据源的基本信息-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="username" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
<property name="url" value="${jdbc.url}"></property>
<property name ="driverClassName" value="${jdbc.driverClass}"</property>
<property name="initialSize" value="${jdbc.initialSize}"></property>
<property name="maxActive" value="${jdbc.maxActive}"></property>
</bean>
<!-- 导入外部的资源文件 c3p0.properties-->
<context:property-placeholder location="classpath:c3p0.properties"/>
<!-- 配置数据源 -->
<bean id="dataSource1" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="${jdbc.user}"></property>
<property name="password" value="${jdbc.password}"></property>
<property name="driverClass" value="${jdbc.driverClass}"></property>
<property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
<property name="initialPoolSize" value="${jdbc.initPoolSize}"> </property>
<property name="maxPoolSize" value="${jdbc.maxPoolSize}"></property>
</bean>
</beans> |
|