用户登录
用户注册

分享至

hibernate setting

  • 作者: IS--7
  • 来源: 51数据库
  • 2021-01-29
您好,发现了问题,我首先在c3p0上加上 调试信息的配置 :
c3p0.debugUnreturnedConnectionStackTraces=true
c3p0.unreturnedConnectionTimeout=90 (我的连接超时时间是60s,所以这设置了90s)
applicationContext数据源配置增加响应配置


果然发现很多未回收的连接,正常情况下超时未回收的连接会有一些,但是不会这么多啊。
经查资料在hibernate sessionFacory中增加配置(http://hi.baidu.com/austincao/item/fc9907da3d854e44fa576861)
Spring3.1去掉了HibernateDaoSupport类。hibernate4需要通过getCurrentSession()获取session。 并且设置
org.springframework.orm.hibernate4.SpringSessionContext

在Spring @Transactional声明式事务管理,”currentSession”的定义为: 当前被 Spring事务管理器 管理的Session,此时应配置:
hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext。

另外在hibernate中使用 sessionFactory.getCurrentSession()获取session时,需要为方法声明事务,为此将sqlserver。



  你确定用的是c3p0的连接池么,先看一下tomcat webpps目录下的项目配置连接池是否正确,如果正确的话,可能是连接池用混了。 你找一下spring的连接池配置,还有hibernate的连接池比对下
软件
前端设计
程序设计
Java相关