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&amp;characterEncoding=utf-8
</property>

出现了问题

  应该是这样的,我少写了一个 j

<property name="connection.url">
  jdbc:mysql://127.0.0.1:3306/personal?useUnicode=true&amp;characterEncoding=utf-8
</property>

所以出现了这样的问题,先看看我们的connection.url是不是正确的

Could not open Hibernate Session for transaction;的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 解决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 ...

  4. Hibernage错误:Could not open Hibernate Session for transaction

    今天客户发来的错误,是SSH框架做的项目,是用户在登陆时候出现的错误,但刷新之后就没问题. 提示错误:Could not open Hibernate Session for transaction. ...

  5. HTTP Status 500 - Could not open Hibernate Session for transaction;

    错误原因: mysql数据库没有连接上 我们来启动mysql 方法1: 管理员身份运行 cmd 输入:  net start mysql 方法2: Windows + R 运行 services.ms ...

  6. 解决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 ...

  7. 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%': 显示结果: +------------------------ ...

  8. [原创]java WEB学习笔记77:Hibernate学习之路---Hibernate 版本 helloword 与 解析,.环境搭建,hibernate.cfg.xml文件及参数说明,持久化类,对象-关系映射文件.hbm.xml,Hibernate API (Configuration 类,SessionFactory 接口,Session 接口,Transaction(事务))

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

  9. Hibernate Session & Transaction详解

    Hibernate Session & Transaction详解 HIbernate中的Session Session是JAVA应用程序和Hibernate进行交互时使用的主要接口,它也是持 ...

随机推荐

  1. 数据持久化之sqlite基本用法

    一.ACID 即原子性(Atomicity).一致性(Consistency).隔离性(Isolation).持久性(Durability). 原子性:整个事务中的所有操作,要么全部完成,要么全部不完 ...

  2. 边工作边刷题:70天一遍leetcode: day 84-3

    Meeting Rooms I/II 要点:这题和skyline类似,利用了interval start有序的特点,从左向右处理,用一个heap来动态表示当前占用rooms的时间段,所以heap的si ...

  3. HDU 1171 Big Event in HDU --暴力+生成函数

    题意:给n种房子,每种房子有一个值val和个数cnt,现在要把这些房子分成两部分,争取两部分总值相等,如果不能相等,让A>B,且A-B最小. 解法:先跑一次生成函数,c[n]表示组成总值为n的方 ...

  4. java 21 - 11 IO流的标准输入流和标准输出流

    标准输入输出流 System类中的两个成员变量: public static final InputStream in "标准"输入流. public static final P ...

  5. Mac必装app-持续更新

    所有软件都是免费,或者有破解版 都可以在google上***for mac 搜索到 Google Chrome Microsoft Office Evernote Skype Alfred AppCl ...

  6. Sublime Text2 安装Package Control

    Sublime Text2是一款轻量级的妖娆的编辑器,想要更多私人定制功能的第一步就是安装Package  Control 这是官网的安装方法: Click the Preferences >  ...

  7. 分享一个刷网页PV的python小脚本

    下面分享一个小脚本,用来刷网页PV. [root@huanqiu ~]# cat www.py #!/usr/bin/python# coding: UTF-8import webbrowser as ...

  8. 两种方式判断类的存在→className getAttribute

    通过className获取 var p = document.getElementsByTagName('p'); for(var i = 0;i <p.length;i++){ if(p[i] ...

  9. 域策略禁用usb

    文档及模板可在 http://pan.baidu.com/s/1qYTcjTy  下载 pro_usb_users.adm  此模板可禁用到 指定盘符,针对用户策略 pro_usb_computers ...

  10. 微软职位内部推荐-SW Engineer for Skype

    微软近期Open的职位: We are the Skype Beijing team. Skype division drives the communications strategy for Mi ...