hibernate+proxool

hibernate的配置文件和proxool的配置文件放同一个目录下.也可以分开,改掉相关路径就可以了.
hibernate配置文件
	<session-factory>
		<property name="hibernate.connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</property> 
			<property name="hibernate.proxool.pool_alias">db</property> 
			<property name="hibernate.proxool.xml">/Proxool.xml</property>

</session-factory>


proxool的配置文件Proxool
<?xml version="1.0" encoding="UTF-8"?>
<!-- the proxool configuration can be embedded within your own application's. 
	Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>
	<proxool>
		<alias>db</alias>
		<!-- 用jTDS连接sqlserver数据库 -->
		<driver-url>
			jdbc:jtds:sqlserver://127.0.0.1:1433/WebSystem
		</driver-url>
		<driver-class>
			net.sourceforge.jtds.jdbc.Driver
		</driver-class>
		<driver-properties>
			<property name="user" value="sa" />
			<property name="password" value="123456" />
		</driver-properties>
		<!-- proxool自动侦察各个连接状态的时间间隔(毫秒),侦察到空闲的连接就马上回收,超时的销毁-->
		<house-keeping-sleep-time>30000</house-keeping-sleep-time>
		<!-- 指因未有空闲连接可以分配而在队列中等候的最大请求数,超过这个请求数的用户连接就不会被接受-->
		<maximum-new-connections>100</maximum-new-connections>
		<!-- 最少保持的空闲连接数-->
		<prototype-count>10</prototype-count>
		<!-- 允许最大连接数,超过了这个连接,再有请求时,就排在队列中等候,最大的等待请求数由maximum-new-connections决定-->
		<maximum-connection-count>100</maximum-connection-count>
		<!-- 最小连接数-->
		<minimum-connection-count>5</minimum-connection-count>
		<!-- 同时最大连接数 -->
		<simultaneous-build-throttle>50</simultaneous-build-throttle>
		<house-keeping-test-sql>
			select getdate()
		</house-keeping-test-sql>
	</proxool>
</something-else-entirely>


web.xml配置,用于监控数据连接状态.可以不配置.
<!-- proxool状态的servlet -->
	<servlet>
		<servlet-name>Admin</servlet-name>
		<servlet-class>
			org.logicalcobwebs.proxool.admin.servlet.AdminServlet
		</servlet-class>
	</servlet>

你可能感兴趣的:(Web,Hibernate,xml,servlet,jdbc)