现在的位置: 首页 > 综合 > 正文

spring的各种dataSource配置

2014年03月28日 ⁄ 综合 ⁄ 共 1894字 ⁄ 字号 评论关闭

  1. <?xml
    version=
    "1.0" encoding="UTF-8"?>  
  2. <beans
    xmlns="http://www.springframework.org/schema/beans"  
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  4. xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"  
  5.   xmlns:jee="http://www.springframework.org/schema/jee"   
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans  
  7.           
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
  8.           
    http://www.springframework.org/schema/context  
  9.           
    http://www.springframework.org/schema/context/spring-context-2.5.xsd  
  10.           
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-2.5.xsd 
      
  11.             http://www.springframework.org/schema/jee
    http://www.springframework.org/schema/jee/spring-jee-2.5.xsd  
      
  12.             http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
      
  13. <context:property-placeholder
    location="classpath:jdbc_config.properties"/>  
  14. <!--
      
  15.   DriverManagerDataSource:在每个连接请求时新建一个连接。  
  16.   SingleConnectionDataSource:在每个连接请求时都返回同一连接。  
  17.   -->  
  18. <bean
    id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">  
  19.   <property
    name="driverClassName" value="${driverClassName}"/>  
  20.   <property
    name="url" value="${url}"/>  
  21.   <property
    name="username" value="${username}"/>  
  22.   <property
    name="password" value="${password}"/>  
  23. </bean>
      
  24. </beans>
      
  25.   

。。。。。 

  1. <context:property-placeholder
    location=
    "classpath:dbcp_config.properties" />  
  2.   <bean
    id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"  
  3.   destroy-method="close">  
  4.   <property
    name="driverClassName" value="${driverClassName}"/>  
  5.   <property
    name="url" value="${url}"/>  
  6.   <property
    name="username" value="${username}"/>  

抱歉!评论已关闭.