Web Application 连接池配置


1. 设置连接池的读取参数文件
 <bean id="propertyConfigurer"
  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
   <list>
    <value>WEB-INF/db.properties</value>
   </list>
  </property>
 </bean>

2. 连接池

 <bean id="sfdc3DataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${driverClassName}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <property name="maxActive" value="${jdbc.maxActive}"/>
        <property name="maxIdle" value="${jdbc.Idle}"/>
        <property name="maxWait" value="${jdbc.maxWait}"/>
        <property name="defaultAutoCommit" value="${jdbc.defaultAutoCommit}"/>
        <property name="removeAbandoned" value="true"/>
        <property name="removeAbandonedTimeout" value="60"/>
    </bean>

3. 存放的参数文件(db.properties)

# postgresql
#driverClassName=org.postgresql.Driver
#jdbc.url=jdbc:postgresql://127.0.0.1:5432/databaseName

# mysql
#driverClassName=com.mysql.jdbc.Driver
#jdbc.url=jjdbc:mysql://localhost/mytest?useUnicode=true&amp;characterEncoding=utf-8

#oracle
#driverClassName=oracle.jdbc.driver.OracleDriver"
#jdbc.url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.25)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)(SERVER=DEDICATED)))

#mssql
driverClassName=com.microsoft.jdbc.sqlserver.SQLServerDriver
jdbc.url=jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=databaseName
jdbc.username=sa
jdbc.password=as
jdbc.maxActive=40
jdbc.Idle=30
jdbc.maxWait=1000
jdbc.defaultAutoCommit=true 

你可能感兴趣的:(Web,jdbc,Microsoft,application,PostgreSQL,sqlserver)