您的位置:首页 > 其它

SSH框架下 Proxool 连接池配置

2011-01-21 00:00 381 查看
第一步.添加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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Proxool 配置