- 浏览: 92940 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
lucy12:
http://www.ulequ.com/lengxiaohu ...
mysql远程访问 -
lucy12:
http://www.ulequ.com/lengxiaohu ...
使用struts2时注意内存泄漏 -
lucy12:
http://www.ulequ.com/lengxiaohu ...
Spring核心总结 -
lucy12:
http://www.ulequ.com/jizhuanwan ...
怎么得到java类当前路径 -
lucy12:
http://www.yulet.com/qiushibaik ...
怎么得到java类当前路径
转自 http://wt8414.iteye.com/blog/242628 收藏参考
基于ssh的proxool连接池配置
环境:MyEclipse5.5,win 2003,oracle,mysql
配置文件1:applicationContext.xml
Xml代码
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"><!-- 数据源类采用JDBC数据源 -->
<property name="driverClassName">
<!-- 将数据库连接交给了proxool管理,使它的驱动 --> <value>org.logicalcobwebs.proxool.ProxoolDriver</value>
</property>
<property name="url">
<!-- 数据库连接池的别名,与你的proxool.xml中的Alias必须一致 -->
<value>proxool.DbPool</value>
</property>
</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.MySQLDialect
</prop>
<prop key="hibernate.connection.autocommit">true</prop>
<prop key="hibernate.show_sql">true</prop>
<!--
此处要注意因为proxool自己释放数据库连接比慢,所以要在此给出释放连接的模式,具体几种模式对应的意思,可以Google一下hibernate.connection.release_mode,有很多说明,在此不多说
-->
<prop key="hibernate.connection.release_mode">
after_statement
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>cn/wt/vo/Admin.hbm.xml</value>
<value>cn/wt/vo/User.hbm.xml</value>
<value>cn/wt/vo/Workdate.hbm.xml</value>
</list>
</property>
</bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="adminDao" class="cn.wt.dao.AdminDao" abstract="true" />
<bean id="adminDaoImpl" class="cn.wt.dao.impl.AdminDaoImpl"
parent="adminDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="workDateDao" class="cn.wt.dao.WorkDateDao"
abstract="true" />
<bean id="workDateDaoImpl" class="cn.wt.dao.impl.WorkDateDaoImpl"
parent="workDateDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="userDao" class="cn.wt.dao.UserDao" abstract="true" />
<bean id="userDaoImpl" class="cn.wt.dao.impl.UserDaoImpl" parent="userDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>
<bean name="/adminAction" class="cn.wt.struts.action.AdminAction">
<property name="adminDao">
<ref bean="adminDaoImpl" />
</property>
</bean>
<bean name="/workdateAction"
class="cn.wt.struts.action.WorkdateAction">
<property name="workDateDao">
<ref bean="workDateDaoImpl" />
</property>
<property name="userDao">
<ref bean="userDaoImpl"/>
</property>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"><!-- 数据源类采用JDBC数据源 -->
<property name="driverClassName">
<!-- 将数据库连接交给了proxool管理,使它的驱动 --> <value>org.logicalcobwebs.proxool.ProxoolDriver</value>
</property>
<property name="url">
<!-- 数据库连接池的别名,与你的proxool.xml中的Alias必须一致 -->
<value>proxool.DbPool</value>
</property>
</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.MySQLDialect
</prop>
<prop key="hibernate.connection.autocommit">true</prop>
<prop key="hibernate.show_sql">true</prop>
<!--
此处要注意因为proxool自己释放数据库连接比慢,所以要在此给出释放连接的模式,具体几种模式对应的意思,可以Google一下hibernate.connection.release_mode,有很多说明,在此不多说
-->
<prop key="hibernate.connection.release_mode">
after_statement
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>cn/wt/vo/Admin.hbm.xml</value>
<value>cn/wt/vo/User.hbm.xml</value>
<value>cn/wt/vo/Workdate.hbm.xml</value>
</list>
</property>
</bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="adminDao" class="cn.wt.dao.AdminDao" abstract="true" />
<bean id="adminDaoImpl" class="cn.wt.dao.impl.AdminDaoImpl"
parent="adminDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="workDateDao" class="cn.wt.dao.WorkDateDao"
abstract="true" />
<bean id="workDateDaoImpl" class="cn.wt.dao.impl.WorkDateDaoImpl"
parent="workDateDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="userDao" class="cn.wt.dao.UserDao" abstract="true" />
<bean id="userDaoImpl" class="cn.wt.dao.impl.UserDaoImpl" parent="userDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>
<bean name="/adminAction" class="cn.wt.struts.action.AdminAction">
<property name="adminDao">
<ref bean="adminDaoImpl" />
</property>
</bean>
<bean name="/workdateAction"
class="cn.wt.struts.action.WorkdateAction">
<property name="workDateDao">
<ref bean="workDateDaoImpl" />
</property>
<property name="userDao">
<ref bean="userDaoImpl"/>
</property>
</bean>
</beans>
配置文件2:/WEB-INF/proxool.xml
Xml代码
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- the proxool configuration can be embedded within your own application's.
Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>
<proxool>
<alias>DbPool</alias> //与applicationContext.xml中url一致
<driver-url>jdbc:mysql://localhost:3306/mysql</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-properties>
<property name="user" value="root" />
<property name="password" value="123" />
<property name="useUnicode" value="true" />
<property name="characterEncoding" value="GBK" />
</driver-properties>
<minimum-connection-count>5</minimum-connection-count>
<maximum-connection-count>50</maximum-connection-count>
<maximum-active-time>60000</maximum-active-time>
<house-keeping-test-sql>select 1</house-keeping-test-sql>
<prototype-count>5</prototype-count>
<house-keeping-sleep-time>60000</house-keeping-sleep-time>
</proxool>
</something-else-entirely>
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- the proxool configuration can be embedded within your own application's.
Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>
<proxool>
<alias>DbPool</alias> //与applicationContext.xml中url一致
<driver-url>jdbc:mysql://localhost:3306/mysql</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-properties>
<property name="user" value="root" />
<property name="password" value="123" />
<property name="useUnicode" value="true" />
<property name="characterEncoding" value="GBK" />
</driver-properties>
<minimum-connection-count>5</minimum-connection-count>
<maximum-connection-count>50</maximum-connection-count>
<maximum-active-time>60000</maximum-active-time>
<house-keeping-test-sql>select 1</house-keeping-test-sql>
<prototype-count>5</prototype-count>
<house-keeping-sleep-time>60000</house-keeping-sleep-time>
</proxool>
</something-else-entirely>
配置文件3:web.xml
Xml代码
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
</param-value>
</context-param>
<servlet>
<servlet-name>proxoolServletConfigurator</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>
<!-- 由于proxool要先加载,所以启动优先级要比spring高,否则在spring加载时会报错 -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<!-- 数据库连接监控器 -->
<servlet-name>proxoolAdmin</servlet-name>
<servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>proxoolAdmin</servlet-name>
<url-pattern>/proxoolAdmin</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
</param-value>
</context-param>
<servlet>
<servlet-name>proxoolServletConfigurator</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>
<!-- 由于proxool要先加载,所以启动优先级要比spring高,否则在spring加载时会报错 -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<!-- 数据库连接监控器 -->
<servlet-name>proxoolAdmin</servlet-name>
<servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>proxoolAdmin</servlet-name>
<url-pattern>/proxoolAdmin</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
基本配置就这些,以前在根据网上所说的很多利用spring直接管理proxool的方法来实现,这种方法也可以,但有几点问题,1.mysql连接的URL:jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=GBK中间的&符号,在xml中使用&来代替,但我在做测试时发现这样做不行,spring在启动时会报没有这样的驱动,还有些根本就是错误的估计是在网上转来转去,没经过测试就发表的.
关于连接释放,在applicationContext.xml中绝对有必要增加hibernate.connection.release_mode这一参数,而且比较的好的设置应该是after_statement,另一种是after_transaction,而使用after_statement优于after_transaction原因是避免了在一个事务结束后连接就释放,大家可以试一下先将这个参数去掉,运几次数据库操作,会发现产了生很多连接没有释放,大概大30秒至15秒之间可以释放有时会更长,然后在加上这个参数测试.
基于ssh的proxool连接池配置
环境:MyEclipse5.5,win 2003,oracle,mysql
配置文件1:applicationContext.xml
Xml代码
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"><!-- 数据源类采用JDBC数据源 -->
<property name="driverClassName">
<!-- 将数据库连接交给了proxool管理,使它的驱动 --> <value>org.logicalcobwebs.proxool.ProxoolDriver</value>
</property>
<property name="url">
<!-- 数据库连接池的别名,与你的proxool.xml中的Alias必须一致 -->
<value>proxool.DbPool</value>
</property>
</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.MySQLDialect
</prop>
<prop key="hibernate.connection.autocommit">true</prop>
<prop key="hibernate.show_sql">true</prop>
<!--
此处要注意因为proxool自己释放数据库连接比慢,所以要在此给出释放连接的模式,具体几种模式对应的意思,可以Google一下hibernate.connection.release_mode,有很多说明,在此不多说
-->
<prop key="hibernate.connection.release_mode">
after_statement
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>cn/wt/vo/Admin.hbm.xml</value>
<value>cn/wt/vo/User.hbm.xml</value>
<value>cn/wt/vo/Workdate.hbm.xml</value>
</list>
</property>
</bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="adminDao" class="cn.wt.dao.AdminDao" abstract="true" />
<bean id="adminDaoImpl" class="cn.wt.dao.impl.AdminDaoImpl"
parent="adminDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="workDateDao" class="cn.wt.dao.WorkDateDao"
abstract="true" />
<bean id="workDateDaoImpl" class="cn.wt.dao.impl.WorkDateDaoImpl"
parent="workDateDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="userDao" class="cn.wt.dao.UserDao" abstract="true" />
<bean id="userDaoImpl" class="cn.wt.dao.impl.UserDaoImpl" parent="userDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>
<bean name="/adminAction" class="cn.wt.struts.action.AdminAction">
<property name="adminDao">
<ref bean="adminDaoImpl" />
</property>
</bean>
<bean name="/workdateAction"
class="cn.wt.struts.action.WorkdateAction">
<property name="workDateDao">
<ref bean="workDateDaoImpl" />
</property>
<property name="userDao">
<ref bean="userDaoImpl"/>
</property>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"><!-- 数据源类采用JDBC数据源 -->
<property name="driverClassName">
<!-- 将数据库连接交给了proxool管理,使它的驱动 --> <value>org.logicalcobwebs.proxool.ProxoolDriver</value>
</property>
<property name="url">
<!-- 数据库连接池的别名,与你的proxool.xml中的Alias必须一致 -->
<value>proxool.DbPool</value>
</property>
</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.MySQLDialect
</prop>
<prop key="hibernate.connection.autocommit">true</prop>
<prop key="hibernate.show_sql">true</prop>
<!--
此处要注意因为proxool自己释放数据库连接比慢,所以要在此给出释放连接的模式,具体几种模式对应的意思,可以Google一下hibernate.connection.release_mode,有很多说明,在此不多说
-->
<prop key="hibernate.connection.release_mode">
after_statement
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>cn/wt/vo/Admin.hbm.xml</value>
<value>cn/wt/vo/User.hbm.xml</value>
<value>cn/wt/vo/Workdate.hbm.xml</value>
</list>
</property>
</bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="adminDao" class="cn.wt.dao.AdminDao" abstract="true" />
<bean id="adminDaoImpl" class="cn.wt.dao.impl.AdminDaoImpl"
parent="adminDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="workDateDao" class="cn.wt.dao.WorkDateDao"
abstract="true" />
<bean id="workDateDaoImpl" class="cn.wt.dao.impl.WorkDateDaoImpl"
parent="workDateDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="userDao" class="cn.wt.dao.UserDao" abstract="true" />
<bean id="userDaoImpl" class="cn.wt.dao.impl.UserDaoImpl" parent="userDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>
<bean name="/adminAction" class="cn.wt.struts.action.AdminAction">
<property name="adminDao">
<ref bean="adminDaoImpl" />
</property>
</bean>
<bean name="/workdateAction"
class="cn.wt.struts.action.WorkdateAction">
<property name="workDateDao">
<ref bean="workDateDaoImpl" />
</property>
<property name="userDao">
<ref bean="userDaoImpl"/>
</property>
</bean>
</beans>
配置文件2:/WEB-INF/proxool.xml
Xml代码
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- the proxool configuration can be embedded within your own application's.
Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>
<proxool>
<alias>DbPool</alias> //与applicationContext.xml中url一致
<driver-url>jdbc:mysql://localhost:3306/mysql</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-properties>
<property name="user" value="root" />
<property name="password" value="123" />
<property name="useUnicode" value="true" />
<property name="characterEncoding" value="GBK" />
</driver-properties>
<minimum-connection-count>5</minimum-connection-count>
<maximum-connection-count>50</maximum-connection-count>
<maximum-active-time>60000</maximum-active-time>
<house-keeping-test-sql>select 1</house-keeping-test-sql>
<prototype-count>5</prototype-count>
<house-keeping-sleep-time>60000</house-keeping-sleep-time>
</proxool>
</something-else-entirely>
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- the proxool configuration can be embedded within your own application's.
Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>
<proxool>
<alias>DbPool</alias> //与applicationContext.xml中url一致
<driver-url>jdbc:mysql://localhost:3306/mysql</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-properties>
<property name="user" value="root" />
<property name="password" value="123" />
<property name="useUnicode" value="true" />
<property name="characterEncoding" value="GBK" />
</driver-properties>
<minimum-connection-count>5</minimum-connection-count>
<maximum-connection-count>50</maximum-connection-count>
<maximum-active-time>60000</maximum-active-time>
<house-keeping-test-sql>select 1</house-keeping-test-sql>
<prototype-count>5</prototype-count>
<house-keeping-sleep-time>60000</house-keeping-sleep-time>
</proxool>
</something-else-entirely>
配置文件3:web.xml
Xml代码
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
</param-value>
</context-param>
<servlet>
<servlet-name>proxoolServletConfigurator</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>
<!-- 由于proxool要先加载,所以启动优先级要比spring高,否则在spring加载时会报错 -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<!-- 数据库连接监控器 -->
<servlet-name>proxoolAdmin</servlet-name>
<servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>proxoolAdmin</servlet-name>
<url-pattern>/proxoolAdmin</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
</param-value>
</context-param>
<servlet>
<servlet-name>proxoolServletConfigurator</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>
<!-- 由于proxool要先加载,所以启动优先级要比spring高,否则在spring加载时会报错 -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<!-- 数据库连接监控器 -->
<servlet-name>proxoolAdmin</servlet-name>
<servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>proxoolAdmin</servlet-name>
<url-pattern>/proxoolAdmin</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
基本配置就这些,以前在根据网上所说的很多利用spring直接管理proxool的方法来实现,这种方法也可以,但有几点问题,1.mysql连接的URL:jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=GBK中间的&符号,在xml中使用&来代替,但我在做测试时发现这样做不行,spring在启动时会报没有这样的驱动,还有些根本就是错误的估计是在网上转来转去,没经过测试就发表的.
关于连接释放,在applicationContext.xml中绝对有必要增加hibernate.connection.release_mode这一参数,而且比较的好的设置应该是after_statement,另一种是after_transaction,而使用after_statement优于after_transaction原因是避免了在一个事务结束后连接就释放,大家可以试一下先将这个参数去掉,运几次数据库操作,会发现产了生很多连接没有释放,大概大30秒至15秒之间可以释放有时会更长,然后在加上这个参数测试.
发表评论
-
jar作用(一)
2009-05-15 11:10 877hibernate2.jar: Hibernate的库,没有 ... -
Struts 2 JFreeChart 插件使用官方文档中文版
2009-04-20 09:25 1970English Version: http://struts. ... -
properties文件的Eclipse插件(plugin)
2009-03-16 16:19 1983在此想和大家分享一个不错的编写properties文件的Ecl ... -
XFire WebService
2009-01-14 17:16 1324在ASP.NET中创建WebService是非常简单的事,但是 ... -
Spring核心总结
2009-01-07 17:10 1173一、 IoC(Inversion of control) ... -
Struts 2权威指南:基于WebWork核心的MVC开发
2009-01-06 22:15 13403.5 Struts 2的基本配置 前面大致了解了Strut ... -
Proxool连接池使用方法
2009-01-06 11:01 1224首先, 你要把下载 proxool ... -
Proxool连接池的使用心得
2009-01-05 21:33 1325公司里用的连接池都是自己写好了,封装起来的,做大型项目的时候, ... -
Proxool连接池实现
2009-01-05 21:29 1010关键字: proxoll 连接池 首先从 http://p ... -
apache的dbcp数据库连接池
2009-01-05 21:12 2196下载这些包并将这些包的路径添加到classpath中就可以使用 ... -
struts.xml和struts.properties (详解struts2中struts.pro
2009-01-05 20:34 1736Struts 2框架有两个核心配置文件: stru ... -
struts2中struts.xml 非默认路径的配置
2009-01-05 20:25 2787转自:http://blog.csdn.net/wbb1983 ...
相关推荐
struts2.2.3+spring2.5.6+hibernate3.2+proxool0.9.1 proxool数据库连接池例子 0资源下载
Struts2+Spring3+Hibernate3+Proxool_亲测成功 费大劲了.zip
Spring+proxool+hibernate+struts2+aop整合的完整的简单项目
Spring+proxool+hibernate+struts2+aop整合的完整_Jar包
本项目采用当前主流的MVC和IOC框架spring 3、优秀的ORM框架hibernate和超级厉害的proxool数据库连接池。这个工程demo,是本人在企业应用中的项目缩影,绝对实用于企业的应用。 适合朋友: 1.一直用单独的servlet和...
proxool(据说是dbcp和c3p0三者中最优秀的)做连接池;使用jquery的ajax实现仿google人名自动补全;头像上传剪切压缩处理。 包含有完整的jar包和源代码,这是专门为我们实验室定制开发的,包含了架构基于s2sh技术...
本版本全面更新了jar包,全部使用了当前最新版本的jar包,struct2.1.8 spring3 hibernate3.5,全面使用注解取代xm的l配置。 另外增加了一个ant构建脚本,支持使用hudson完成每日构建,持续集成,自动测试,代码规范...
Extjs3.2+struts2.0+spring2.5+hibernate3.5+weblogic10+oracle10g 第4部分
NULL 博文链接:https://devsky.iteye.com/blog/1038804
本版本全面更新了jar包,全部使用了当前最新版本的jar包,struct2.1.8 spring3 hibernate3.5,全面使用注解取代xm的l配置。 另外增加了一个ant构建脚本,支持使用hudson完成每日构建,持续集成,自动测试,代码规范...
struts2.2.1 spring2.5.6 proxool0.9.1 jstl1.2 说明:demo实现了最简单的取值,数据库操作。 没有使用hibernate和ibatis。自己写了个基类,包装了获取链接和释放链接。 从action返回后,使用了jstl获取action中的...
proxool_cofig.xml为连接池配置 此项目可做基础项目开发原型方便,启动此项目在weblogic10中会有antlr-2.7.6rc1.jar此包的异常请配置其先加载并将次包考入 bea\wlserver_10.0\server\lib目录下,再将bea\user_projects...
struts2+hibernate3.2+spring2.5 proxool成步骤
本版本全面更新了jar包,全部使用了当前最新版本的jar包,struct2.1.8 spring3 hibernate3.5,全面使用注解取代xm的l配置。 另外增加了一个ant构建脚本,支持使用hudson完成每日构建,持续集成,自动测试,代码规范...
spring3.0.4+hibernate3.5.0+proxool 0.9.1+jstl整合最新的JAVA WEB框架,没有使用struts2,视图层使用spring MVC.
本版本全面更新了jar包,全部使用了当前最新版本的jar包,struct2.1.8 spring3 hibernate3.5,全面使用注解取代xm的l配置。 另外增加了一个ant构建脚本,支持使用hudson完成每日构建,持续集成,自动测试,代码规范...
利用ssh(Spring2.5+Struts2.1+Hibernate3.3)全注解整合这3个流行的框架,实现了增、删、改、查的功能,目前功能还比较简单,以后功能再慢慢增加。欢迎大家下载并交流。
所以没有上传导入的jar,其实就是默认的struts2和hibernate以及spring的包.该项目使用的jar包为以下. spring-beans.jar xwork-2.0.4.jar spring-context.jar ognl-2.6.11.jar spring-web.jar ...
struts2+spring2.5+hibernate3.2整合所需的所有jar包,并额外包含了dwr.jar、分页组件pager-taglib、绘图组件jfreechart.jar、Excel解析工具包jxl.jar、数据库连接池工具包proxool.jar
本项目采用Struts2、Hibernate3集成JPA2、Spring3和Proxool连接池的集成,对整体SSH框架的数据访问及网站效率都有较大的提升,本项目即时部署即可使用,既满足新手的学习,也对有深层研究的朋友有帮助。