Struts2+Spring+Hibernate配置Proxool连接池

三步走:

 

第一步:在Spring的配置文件中加入:

 

	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="configLocation">
			<value>classpath:hibernate.cfg.xml</value>
		</property>
	</bean>

 

 第二步:在Hibernate配置文件中加入:

 

<session-factory>
		<property name="hibernate.proxool.pool_alias">
			DBPool
		</property>
		<property name="hibernate.proxool.xml">pool.xml</property>
		<property name="hibernate.connection.provider_class">
			org.hibernate.connection.ProxoolConnectionProvider
		</property>
		<property name="hibernate.proxool.existing_pool">false</property>
		<property name="dialect">
			org.hibernate.dialect.Oracle9iDialect
		</property>
		<property name="hibernate.show_sql">true</property>
</session-factory>

 

第三步:增加pool.xml文件,内容如下:

 

<?xml version="1.0" encoding="UTF-8"?>
<something-else-entirely>
	<proxool>
		<alias>DBPool</alias>
		<driver-url>
			jdbc:oracle:thin:@192.168.1.166:1521:test
		</driver-url>
		<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
		<driver-properties>
			<property name="user" value="test" />
			<property name="password" value="test" />
		</driver-properties>
		<!-- 连接最大活动时间(毫秒)-->
		<maximum-active-time>120000</maximum-active-time>
		<!-- 连接最大生命时间 (毫秒)-->
		<maximum-connection-lifetime>36000000</maximum-connection-lifetime>
		<!-- 侦测状时间(毫秒) -->
		<house-keeping-sleep-time>60000</house-keeping-sleep-time>
		<!-- 并发数 -->
		<simultaneous-build-throttle>200</simultaneous-build-throttle>
		<!-- 每次新增连接数 -->
		<prototype-count>2</prototype-count>
		<!-- 最大连接数量 -->
		<maximum-connection-count>300</maximum-connection-count>
		<!-- 最小连接数量 -->
		<minimum-connection-count>5</minimum-connection-count>
	</proxool>
</something-else-entirely>

 

 

你可能感兴趣的:(spring,oracle,Hibernate,bean,xml)