jdbc.properties文件:
#driver= oracle.jdbc.driver.OracleDriver
driver=com.mysql.jdbc.Driver
#url=jdbc:oracle:thin:@127.0.0.1:1521:test
url=jdbc:mysql://127.0.0.1:3306/test
username=root
password=12345
方法一:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:property-placeholder location="classpath:jdbc.properties"/>
<!--<context:component-scan base-package="com"></context:component-scan> -->
<bean id="dataSource_1" class="org.logicalcobwebs.proxool.ProxoolDataSource" >
<property name="driver" value="${driver}"/>
<property name="driverUrl" value="${url}"/>
<property name="user" value="${username}"/>
<property name="password" value="${password}" />
<property name="maximumActiveTime" value="${maximumActiveTime}" />
</bean >
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" >
<property name="driver" value="${driver}"/>
<property name="driverUrl" value="${url}"/>
<property name="user" value="${username}"/>
<property name="password" value="${password}"/>
<property name="maximumConnectionCount" value="200" ></property>
</bean>
方法二:
<beans
xmlns="http://www.springframework.org/schema/beans"
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-2.5.xsd">
<!--配置数据源属性文件 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>/WEB-INF/configs/sqlServer.properties</value>
</property>
</bean>
<!--配置数据源 -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>${jdbc.driver}</value>
</property>
<property name="url" >
<value>${jdbc.url}</value>
</property>
<property name="username" >
<value>${jdbc.user}</value>
</property>
<property name="password">
<value>${jdbc.pwd}</value>
</property>
</bean>