proxool与hibernate配置
proxool 介绍请看:
http://proxool.sourceforge.net/
you can download here!
http://proxool.sourceforge.net/download.html
我的hibernate采用properties方式配置,下面介绍我做的两种配置:
========================
配置一:使用proxool.properties
设置proxool的监控servlet
web.xml
<servlet>
<servlet-name>ServletConfigurator</servlet-name>
<servlet-class>org.logicalcobwebs.proxool.configuration.ServletConfigurator</servlet-class>
<init-param>
<param-name>propertyFile</param-name>
<param-value>WEB-INF/classes/Proxool.properties</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Admins</servlet-name>
<servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Admins</servlet-name>
<url-pattern>/Admins</url-pattern>
</servlet-mapping>
2.hibernate.properties
使用 proxool.properties 配置:
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
hibernate.connection.driver_class=oracle.jdbc.OracleDriver
hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory
connection.useUnicode=true
connection.characterEncoding=UTF-8
hibernate.show_sql=false
hibernate.connection.provider_class=org.hibernate.connection.ProxoolConnectionProvider
hibernate.proxool.pool_alias DBPool
hibernate.proxool.properties proxool.properties
proxool.properties
jdbc-1.proxool.alias=DBPool
jdbc-1.proxool.driver-class=oracle.jdbc.driver.OracleDriver
jdbc-1.proxool.driver-url=jdbc:oracle:thin:@172.10.0.111:1521:2hei
jdbc-1.user=2hei
jdbc-1.password=2hei.net
jdbc-1.proxool.maximum-connection-count=20
jdbc-1.proxool.prototype-count=4
jdbc-1.proxool.house-keeping-test-sql=select sysdate from DUAL
jdbc-1.proxool.verbose=true
jdbc-1.proxool.statistics=10s,1m,1d
jdbc-1.proxool.statistics-log-level=ERROR
配置二:使用proxool.xml
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
hibernate.connection.driver_class=oracle.jdbc.OracleDriver
hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory
connection.useUnicode=true
connection.characterEncoding=UTF-8
hibernate.show_sql=false
hibernate.connection.provider_class=org.hibernate.connection.ProxoolConnectionProvider
hibernate.proxool.pool_alias DBPool
hibernate.proxool.xmlproxool.xml ### 与配置的区别
vi classes/proxool.xml
<?xml version=”1.0″ encoding=”utf-8″?>
<something-else-entirely>
<proxool>
<alias>DBPool</alias>
<driver-url>jdbc:oracle:thin:@172.10.0.111:1521:2hei</driver-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<driver-properties>
<property name=”user” value=”2hei”/>
<property name=”password” value=”2hei.net”/>
</driver-properties>
<house-keeping-sleep-time>90000</house-keeping-sleep-time>
<maximum-new-connections>20</maximum-new-connections>
<prototype-count>5</prototype-count>
<maximum-connection-count>100</maximum-connection-count>
<minimum-connection-count>10</minimum-connection-count>
<house-keeping-test-sql>select sysdate from dual</house-keeping-test-sql>
</proxool>
</something-else-entirely>
下面是监控记录:
看到active connection 数量始终为0,以为自己的配置有些问题,
后来采用了压力测试软件,施加点压力(50*10),感觉连接池对数据的压力还是比较敏感,
管理界面显示当available connection 达到最大值后,不会立即消失,而是保持一段时间,
此时的连接数保持较大的数量也应该对服务器不会产生坏影响。
本文固定链接: https://www.2hei.net/2008/03/13/proxool_hibernate_setting/ | 2hei.net
最活跃的读者