第一种:直接在applicationContext.xml中配置

    ......
    ......
<!--创建数据源 -->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
        <property name="url" value="jdbc:mysql://localhost:3306/test"></property>
        <property name="username" value="root"></property>
        <property name="password" value="root"></property>
    </bean>
    ......
    ......

另外一种:配置properties文件。然后在applicationContext.xml读取,相对第一种方式,另外一种方式更为灵活。

properties文件:DbxoolConnection.properties

db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/test?

useUnicode=true&amp;characterEncoding=UTF-8 db.user=root db.password=root db.alias=QZCDBPool db.houseKeepingTestSql=select 1 db.characterEncoding=UTF-8 db.maximumConnectionCount=100 db.minimumConnectionCount=10

applicationContext.xml文件:

    ......
    ......
        <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
          <property name="locations">
            <list>
                <value> 
                classpath:DbxoolConnection.properties
                </value>
            </list>
           </property>
        </bean> 


     <bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource"> 
        <property name="driver" value="${db.driver}"/>
        <property name="driverUrl" value="${db.url}"/>
        <property name="user" value="${db.user}"/>
        <property name="password" value="${db.password}"/>
        <property name="alias" value="${db.alias}"/>
        <property name="houseKeepingTestSql" value="${db.houseKeepingTestSql}"/>
        <property name="maximumConnectionCount" value="${db.maximumConnectionCount}"/>
        <property name="minimumConnectionCount" value="${db.minimumConnectionCount}"/>
        <property name="delegateProperties" value="characterEncoding=${db.characterEncoding}"/>
     </bean>    
       ......
       ......

需注意导入org.logicalcobwebs.proxool.ProxoolDataSource引用的包:proxool-0.9.1.jar