SSH框架下 Proxool 连接池配置

第一步.添加jar包:proxool-0.9.1.jar,proxool-cglib.jar 在WEB-INF下,创建proxool.xml文件,代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<proxool>
 <alias>sqlserver2000</alias>
 <driver-url>jdbc:sqlserver://192.168.1.123:1433;databaseName=Test</driver-url>
 <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
 <driver-properties>
  <property name="user" value="admin" />
  <property name="password" value="admin" />
 </driver-properties>
 <maximum-connection-count>50</maximum-connection-count>
 <minimum-connection-count>5</minimum-connection-count>
</proxool>
第二步.web.xml中加入以下代码:

 <servlet-name>ServletConfigurator</servlet-name>
  <servlet-class>org.logicalcobwebs.proxool.configuration.ServletConfigurator</servlet-class>
  <init-param>
   <param-name>xmlFile</param-name>
   <param-value>WEB-INF/proxool.xml</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
 </servlet>

第三步.在Spring的配置文件applicationContext.xml中代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
 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-2.5.xsd
 http://www.springframework.org/schema/context
 http://www.springframework.org/schema/context/spring-context-2.5.xsd
 http://www.springframework.org/schema/tx
 http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
 ">

 <tx:annotation-driven />
 <context:component-scan base-package="com.xxx"></context:component-scan>

 <bean id="dataSource"
  class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  <property name="url" value="proxool.sqlserver2000" />
 </bean>
 <bean id="sessionFactory"
  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource">
   <ref bean="dataSource" />
  </property>
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect
    </prop>

    <prop key="hibernate.show_sql">
     true
    </prop>
   </props>
  </property>

  <property name="mappingDirectoryLocations">
   <list>
    <value>classpath:com/xxx/pojo/</value>
   </list>
  </property>
  </bean>
 <bean id="transactionManager"
  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory" ref="sessionFactory"></property>
 </bean>
</beans>

转载于:https://my.oschina.net/terrycz/blog/12503

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值