- 浏览: 95676 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
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 922hibernate2.jar: Hibernate的库,没有 ... -
Struts 2 JFreeChart 插件使用官方文档中文版
2009-04-20 09:25 2014English Version: http://struts. ... -
properties文件的Eclipse插件(plugin)
2009-03-16 16:19 2021在此想和大家分享一个不错的编写properties文件的Ecl ... -
XFire WebService
2009-01-14 17:16 1381在ASP.NET中创建WebService是非常简单的事,但是 ... -
Spring核心总结
2009-01-07 17:10 1206一、 IoC(Inversion of control) ... -
Struts 2权威指南:基于WebWork核心的MVC开发
2009-01-06 22:15 13883.5 Struts 2的基本配置 前面大致了解了Strut ... -
Proxool连接池使用方法
2009-01-06 11:01 1267首先, 你要把下载 proxool ... -
Proxool连接池的使用心得
2009-01-05 21:33 1366公司里用的连接池都是自己写好了,封装起来的,做大型项目的时候, ... -
Proxool连接池实现
2009-01-05 21:29 1070关键字: proxoll 连接池 首先从 http://p ... -
apache的dbcp数据库连接池
2009-01-05 21:12 2257下载这些包并将这些包的路径添加到classpath中就可以使用 ... -
struts.xml和struts.properties (详解struts2中struts.pro
2009-01-05 20:34 1768Struts 2框架有两个核心配置文件: stru ... -
struts2中struts.xml 非默认路径的配置
2009-01-05 20:25 2819转自:http://blog.csdn.net/wbb1983 ...
相关推荐
文件`Spring3+Hibernate+Proxool_lj配置试验成功.txt`表明Spring3和Hibernate已经成功地集成了Proxool,这可能涉及到了Spring的`DataSource`配置,通过`<bean>`标签定义一个数据源,然后在Hibernate配置中引用它。...
Struts2.2.3、Spring2.5.6、Hibernate3.2和Proxool0.9.1是四个重要的Java技术组件,它们在Web应用程序开发中扮演着关键角色。这个压缩包文件包含了这些技术的集成示例,旨在帮助开发者理解和实践如何将它们有效地...
在"Spring+proxool+hibernate+struts2+aop"的整合中,Spring负责整体的依赖管理和事务控制,Struts2处理请求转发和视图展示,Hibernate处理数据库操作,而AOP则用来实现跨切面的关注点。 在提供的"Spring+proxool+...
**Spring+Proxool+Hibernate+Struts2+AOP整合详解** 在Java Web开发中,Spring、Proxool、Hibernate、Struts2和AOP(面向切面编程)是常用的框架和技术,它们各自承担着不同的职责,组合使用可以构建出高效、可维护...
本项目采用当前主流的MVC和IOC框架spring 3、优秀的ORM框架hibernate和超级厉害的proxool数据库连接池。这个工程demo,是本人在企业应用中的项目缩影,绝对实用于企业的应用。 适合朋友: 1.一直用单独的servlet和...
proxool(据说是dbcp和c3p0三者中最优秀的)做连接池;使用jquery的ajax实现仿google人名自动补全;头像上传剪切压缩处理。 包含有完整的jar包和源代码,这是专门为我们实验室定制开发的,包含了架构基于s2sh技术...
本文将详细介绍如何在Struts2+Spring+Hibernate的环境中配置Proxool连接池。 首先,理解Proxool的工作原理。Proxool是一个基于池化的JDBC代理,它维护着一个数据库连接池,当应用需要访问数据库时,可以从池中获取...
Extjs3.2+struts2.0+spring2.5+hibernate3.5+weblogic10+oracle10g 第4部分
在完成上述配置后,需要进行集成测试,确保请求能够正确地通过Struts2控制器,调用Spring管理的Service,再由Service调用Hibernate的DAO,最后正确地与数据库进行交互。 整合Struts2、Spring和Hibernate可以实现...
本版本全面更新了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...
本版本全面更新了jar包,全部使用了当前最新版本的jar包,struct2.1.8 spring3 hibernate3.5,全面使用注解取代xm的l配置。 另外增加了一个ant构建脚本,支持使用hudson完成每日构建,持续集成,自动测试,代码规范...
本版本全面更新了jar包,全部使用了当前最新版本的jar包,struct2.1.8 spring3 hibernate3.5,全面使用注解取代xm的l配置。 另外增加了一个ant构建脚本,支持使用hudson完成每日构建,持续集成,自动测试,代码规范...
《Spring3+Hibernate3+Proxool+jstl+Oracle整合详解》 在现代Java Web开发中,集成各种框架以实现高效、灵活的应用程序已成为常态。本示例代码结合了Spring 3.0.4、Hibernate 3.5.0、Proxool 0.9.1、jstl,并利用...
本版本全面更新了jar包,全部使用了当前最新版本的jar包,struct2.1.8 spring3 hibernate3.5,全面使用注解取代xm的l配置。 另外增加了一个ant构建脚本,支持使用hudson完成每日构建,持续集成,自动测试,代码规范...
Struts2+Spring3+HibernateBBS源码lib2.rar是一个经典的Java Web开发示例,它结合了三个流行的技术框架:Struts2、Spring3和Hibernate,用于构建一个基于论坛的Web应用程序。这个压缩包包含了运行该应用所需的核心库...
在IT行业中,集成Struts2、Hibernate3.2和Spring2.5这三大框架是构建高效、可维护的企业级Web应用程序的常见选择。这三者分别负责MVC(Model-View-Controller)架构中的表现层、持久化层和业务逻辑层的管理。下面将...
【SSH集成】指的是将Struts2、Hibernate3.2和Spring2.5这三大主流Java Web框架进行整合,以构建高效、松耦合的企业级应用。这个集成方案旨在利用Struts2作为MVC(Model-View-Controller)框架处理前端请求,通过...