SSH框架下 Proxool 连接池配置

空扰寡人 提交于 2019-12-05 05:23:27

第一步.添加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>

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!