安装milter-limit配置postfix限制邮件账号发送量
2012-11-03 15:28
716 查看
弄了3天,还是没有搞定。
配置:
winxp+tomcat5.0.28+hibernate3.1+spring1.2.6+struts1.0+mysql5.0.17,做了一个小blog。没有配置连接池时,运转良好。用c3p0配置后,每次都会出现3或者5个新连接。然后发现数据库连接不能释放。出现很多sleep连接。直到全部连接占满。
出现:错误表现:
数据库的表现是:
类似的问题,但没有都没有很好的解决方法。
引用06-21-2006 spring论坛一问题。
http://forum.springframework.org/showthread.php?t=26124
JavaEye
求助,Spring+Hibernate连接池无法释放问题,贴出详细代码
http://www.iteye.com/topic/32378下面是applicationContext.xml的配置:
c3p0.properties的配置是:
BlogDaoimpl的代码是:
请各位高手帮我看看,到底是什么原因(连接池问题,还是代码问题(不用连接池运转良好)导致数据库sleep连接不能释放。谢谢!
配置:
winxp+tomcat5.0.28+hibernate3.1+spring1.2.6+struts1.0+mysql5.0.17,做了一个小blog。没有配置连接池时,运转良好。用c3p0配置后,每次都会出现3或者5个新连接。然后发现数据库连接不能释放。出现很多sleep连接。直到全部连接占满。
出现:错误表现:
javax.servlet.ServletException: Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [null]; error code [0]; Connections could not be acquired from the underlying database!; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database
数据库的表现是:
类似的问题,但没有都没有很好的解决方法。
引用06-21-2006 spring论坛一问题。
http://forum.springframework.org/showthread.php?t=26124
JavaEye
求助,Spring+Hibernate连接池无法释放问题,贴出详细代码
http://www.iteye.com/topic/32378下面是applicationContext.xml的配置:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <!-- for properties files --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:c3p0.properties</value> </list> </property> </bean> <!-- for dataSource --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="${jdbc.driver}" /> <property name="jdbcUrl" value="${jdbc.url}" /> <property name="properties"> <props> <prop key="c3p0.minPoolSize">${hibernate.c3p0.minPoolSize}</prop> <prop key="hc3p0.maxPoolSize">${hibernate.c3p0.maxPoolSize}</prop> <prop key="hc3p0.timeout">${hibernate.c3p0.timeout}</prop> <prop key="c3p0.max_statement">${hibernate.c3p0.max_statement}</prop> <prop key="user">${jdbc.username}</prop> <prop key="password">${jdbc.password}</prop> <prop key="c3p0.testConnectionOnCheckout">true</prop> </props> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="mappingResources"> <list> <value>com/voff/hibernate/Blog.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql"> true </prop> <prop key="hibernate.connection.provider_class"> org.hibernate.connection.C3P0ConnectionProvider </prop> </props> </property> </bean> <!-- transactionManager --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="BlogDao" class="com.voff.dao.BlogDaoimpl"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <!-- spring dao proxy --> <bean id="BlogDaoProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"> <ref bean="transactionManager"/> </property> <property name="proxyInterfaces"> <list> <value>com.voff.dao.BlogDao</value> </list> </property> <property name="target"> <ref bean="BlogDao"/> </property> <property name="transactionAttributes"> <props> <prop key="insert">PROPAGATION_REQUIRED</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="find*">PROPAGATION_REQUIRED</prop> <prop key="*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean> </beans>
c3p0.properties的配置是:
jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost/spring?useUnicode=true&characterEncoding=UTF-8 jdbc.username=root jdbc.password= hibernate.c3p0.minPoolSize=5 hibernate.c3p0.maxPoolSize=20 hibernate.c3p0.timeout=100 hibernate.c3p0.max_statement=50
BlogDaoimpl的代码是:
package com.voff.dao; import java.util.ArrayList; import java.util.List; import org.hibernate.Query; import org.hibernate.Session; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import com.voff.hibernate.Blog; public class BlogDaoimpl extends HibernateDaoSupport implements BlogDao{ public void addblog(Blog blog) { getHibernateTemplate().save(blog); } public void delblog(int id) { Object blog=getHibernateTemplate().load(Blog.class,id); getHibernateTemplate().delete(blog); } public void updateblog(Blog blog) { getHibernateTemplate().update(blog); } public Blog getblog(int id){ return (Blog) getHibernateTemplate().get(Blog.class,id); } public int Totallimitblog(int caid,String bauthor){ String sql = "from Blog where cateid='"+caid+"' and bauthor ='"+bauthor+"'"; List total = getHibernateTemplate().find(sql); return total.size(); } public ArrayList showblog(int firstRow,int maxRow,int caid,String bauthor){ List list=new ArrayList(); Session session = getHibernateTemplate().getSessionFactory().openSession(); Query query =session.createQuery("from Blog where cateid='"+caid+"' and bauthor ='"+bauthor+"' order by blogid desc"); query.setFirstResult(firstRow); query.setMaxResults(maxRow); list=query.list(); session.flush(); session.close(); return (ArrayList) list; } }
请各位高手帮我看看,到底是什么原因(连接池问题,还是代码问题(不用连接池运转良好)导致数据库sleep连接不能释放。谢谢!
相关文章推荐
- PostFix的安装配置,python发送邮件示例
- postfix安装milter-limit限制发件频率
- 在Linux中安装配置Postfix来搭建邮件发送服务
- CentOS6.5_64位系统下安装配置postfix邮件系统 启用并配置SMTP在第三方上边使用发送邮件
- CentOS6.5_64位系统下安装配置postfix邮件系统 启用并配置SMTP在第三方上边使用发送邮件
- ubuntu下安装redmine及其邮件发送的配置
- 邮件系统postfix安装与配置(一)
- Centos6.3安装postfix实现邮件发送
- 邮件系统postfix详细安装与配置
- Seafile深入学习(十六)之 发送邮件提醒 以及 windows域控设置组策略 对所有PC自动安装和配置Seafile客户端
- 邮件系统postfix安装与配置(一)--2
- Linux上配置postfix发送邮件
- CentOS6.5_64位系统下安装配置postfix邮件系统 启用并配置SMTP虚拟账户
- Liunx服务器上编辑邮件系统postfix配置文件和安装dovecot
- Ubuntu 中sendmail 的安装、配置与发送邮件的具体实现
- 邮件系统postfix安装与配置
- LNMP笔记:Centos下安装Postfix,替换sendmail发送邮件
- CentOS 6.x 下Postfix和dovecot邮件服务安装和基本配置
- sendmail 的安装、配置与发送邮件的具体实现
- linux下Postfix邮件服务安装和基本配置