Could not open Hibernate Session for transaction;
javax.servlet.ServletException: org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionException: JDBC begin failed:
这个问题,我在网上找的答案是:
1.
给jdbc url 增加 autoReconnect=true 一定能解决你的问题,可以定期观察一下 show processlist
改进方法如下:
<property name="url" value="jdbc:mysql://localhost/数据库实例名
称?&useUnicode=true&characterEncoding=utf-8&autoReconnect=true"/> 2.
寻找支持重连的连接池。
注意:c3p0连接池支持重连;重连参数是:
idleConnectionTestPeriod 设置空闲连接测试周期
preferredTestQuery : 设置一查询语句,用于重连测试
testConnectionOnCheckin设置为true
testConnectionOnCheckout设置为true 在sessionFactory里配置:
<property name="hibernateProperties">
<props>
<prop key="hibernate.autoReconnect">true</prop>
</props>
</property> 但是最后我都不是这些问题,我发现我的
<property name="connection.url">
dbc:mysql://127.0.0.1:3306/personal?useUnicode=true&characterEncoding=utf-8
</property>
出现了问题
应该是这样的,我少写了一个 j
<property name="connection.url">
jdbc:mysql://127.0.0.1:3306/personal?useUnicode=true&characterEncoding=utf-8
</property>
所以出现了这样的问题,先看看我们的connection.url是不是正确的
Could not open Hibernate Session for transaction;的更多相关文章
- SSH项目过一段时间之后再访问会报一次Could not open Hibernate session for transaction 异常,Caused by: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlyi,再重新方法即可访问成功(通常出现在过了一晚之后再去访问系统)
前端时间到客户那去进行项目的上线测试,将项目部署好之后,运行都是正常的,可是每到了第二天早上访问的时候,就会报一个Could not open Hibernate session for transa ...
- org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Cannot open con
org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session f ...
- 解决Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/transaction/spi/TransactionContext
我使用的是5.2.8的hibernate的jar包,运行的时候却报错Could not open Hibernate Session for transaction; nested exception ...
- Hibernage错误:Could not open Hibernate Session for transaction
今天客户发来的错误,是SSH框架做的项目,是用户在登陆时候出现的错误,但刷新之后就没问题. 提示错误:Could not open Hibernate Session for transaction. ...
- HTTP Status 500 - Could not open Hibernate Session for transaction;
错误原因: mysql数据库没有连接上 我们来启动mysql 方法1: 管理员身份运行 cmd 输入: net start mysql 方法2: Windows + R 运行 services.ms ...
- 解决Exception:Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/transaction/spi/TransactionContext
原因是配置文件中 <bean id="transactionManager" class="org.springframework.orm.hibernate4.H ...
- Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionExcep linux下mysql修改连接超时wait_timeout修改后就ok了
Linux下mysql修改连接超时wait_timeout 1,首先: show variables like '%timeout%': 显示结果: +------------------------ ...
- [原创]java WEB学习笔记77:Hibernate学习之路---Hibernate 版本 helloword 与 解析,.环境搭建,hibernate.cfg.xml文件及参数说明,持久化类,对象-关系映射文件.hbm.xml,Hibernate API (Configuration 类,SessionFactory 接口,Session 接口,Transaction(事务))
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- Hibernate Session & Transaction详解
Hibernate Session & Transaction详解 HIbernate中的Session Session是JAVA应用程序和Hibernate进行交互时使用的主要接口,它也是持 ...
随机推荐
- 搜索+剪枝 POJ 1416 Shredding Company
POJ 1416 Shredding Company Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5231 Accep ...
- Android系列之UI组件----Menu菜单
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...
- AC日记——逃出克隆岛 (bfs)
2059 逃出克隆岛 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 题目描述 Description oi小组的yh酷爱玩魔兽rpg,每天都 ...
- DoTween(HOTween V2) 教程
DoTween资料 官方网站:http://dotween.demigiant.com/ 下载地址:http://dotween.demigiant.com/download.php 快速开始:htt ...
- MySchool
USE [MySchool] GO /****** Object: Table [dbo].[Grade] Script Date: 08/06/2014 15:03:17 ******/ SET A ...
- ASP代码审计一枚
<% On Error Resume Next dim name, pass, sql, action set conn = server.CreateObject("ADODB.Co ...
- request模块提交数据
http://ctf8.shiyanbar.com/jia/ #coding:utf-8import re,requestsurl = r"http://ctf8.shiyanbar.com ...
- sql windows server2008 全套激活码
vs2012 - Microsoft Visual Studio Ultimate 2012 旗舰版 有效注册密钥: YKCW6-BPFPF-BT8C9-7DCTH-QXGWC- Microsoft ...
- js正则匹配只能输入有效数字可加小数点
var reg = /^\d+\.?\d*$/; if(value.search(/^\d+\.?\d*$/)===0 && parseFloat(value)>0){//只能输 ...
- 分布式监控系统Zabbix-3.0.3-完整安装记录(5)-邮件报警部署
前面几篇陆续介绍了zabbix3.0.3监控系统的部署和监控项配置,今天这里分享下zabbix3.0.3的邮件报警的配置过程~由于采用sendmail发送邮件,常常会被认为是垃圾邮件被拒,所以不推荐这 ...