org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session

来源:互联网 发布:船舶吨位是指 知乎 编辑:程序博客网 时间:2024/06/06 00:47

我在用Struts+Spring+Hibernate架构开发web项目时,在eclipse中启动tomcat没问题,能正常连接到数据库,但是我将项目上传到网站空间再进行数据库连接时遇到了Could not open Hibernate Session for transaction。最后我解决了这个问题。我现在把问题贴在了下面!我最终确定是因为数据链接自动关闭,而不是spring和hibernate的问题。

解决办法是:寻找支持重连的连接池。

 在sessionFactory里配置:

<property name="hibernateProperties">
   <props>

        <prop key="hibernate.autoReconnect">true</prop>

  </props>
</property>




转自:http://lxinchang2008.blog.163.com/blog/static/107304898201171165631943

0 0