Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Cannot open connection
Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Cannot open connection
检查一下 数据源 配置, 看你的异常应该是 使用 JTA 事物 ,容器没有实例化 EntityManager
<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="jun" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect"/><!--数据库方言-->
<property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver"/><!--数据库驱动类-->
<property name="hibernate.connection.username" value=""/><!--数据库用户名-->
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url"
value="jdbc:mysql://localhost:3306/mytest;"/><!--数据库连接URL-->
<property name="hibernate.max_fetch_depth" value="3"/><!--外连接抓取树的最大深度 -->
<property name="hibernate.hbm2ddl.auto" value="update"/><!-- 自动输出schema创建DDL语句 -->
<property name="hibernate.jdbc.fetch_size" value="18"/><!-- JDBC的获取量大小 -->
<property name="hibernate.jdbc.batch_size" value="10"/><!-- 开启Hibernate使用JDBC2的批量更新功能 -->
<property name="hibernate.show_sql" value="true"/><!-- 在控制台输出SQL语句 -->
</properties>
</persistence-unit>
</persistence>
Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Cannot open connection的更多相关文章
- spring boot配置spring-data-jpa的时候报错CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NoSuchMethodError
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager f ...
- [springboot jpa] [bug] Could not open JPA EntityManager for transaction
前言 最近,测试环境遇到了一个问题.经过一番百度加谷歌,终于解决了这个问题.写下这篇博客是为了记录下解决过程,以便以后查看.也希望可以帮助更多的人. 环境 java版本:8 框架:spring clo ...
- 使用JPA保存对象时报nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOnly错误
使用JPA保存对象时报nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOn ...
- [Spring Data JPA问题]Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException
JPQL如下: @Modifying(clearAutomatically = true) @Query("UPDATE SyncTestFromTKDO SET stuAns = '' w ...
- Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: No Persistence provider for EntityManager named null
swing Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: No Pe ...
- No transactional EntityManager available; nested exception is javax.persistence.TransactionRequiredException: No transactional EntityManager available
参考地址:http://docs.spring.io/spring-data/jpa/docs/current/api/org/springframework/data/jpa/repository/ ...
- 报错:org.springframework.dao.InvalidDataAccessApiUsageException: Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException: Executing an update/delete query
service实现类上没有加@transaction 事务注解
- javax.persistence.PersistenceException: No Persistence provider for EntityManager named ...
控制台下输出信息 原因:persistence.xml必须放在src下META-INF里面. 若误放在其他路径,就会迷路.
- JPA EntityManager详解(一)
JPA EntityManager详解(一) 持久化上下文(Persistence Contexts)的相关知识,内容包括如何从Java EE容器中创建EntityManager对象.如何从Java ...
随机推荐
- Android Message handling (based on KK4.4)
一.几个关键概念 1.MessageQueue:是一种数据结构,见名知义,就是一个消息队列.存放消息的地方.每个线程最多仅仅能够拥有一个MessageQueue数据结构. 创建一个线程的时候,并不会自 ...
- ARDUINO MEGA2560 经过ESP8266 WIFI模块上传温湿度数据到 OneNet 服务器
简述 原来写了一个C++的wifi库但是发现用c++ arduino这小身板有点扛不住,代码比较大,使用String类型数据处理速度慢,而且很容易无缘无故跑飞.而且封装成库后使用还需要修改arduin ...
- Shell传参的多种方式
Shell 传参的多种方式 使用$1 $2 这种类似占位符的方式 # 命令行调用 start.sh 8080 9090 # 脚本中获取 port1=$1 # 8080 port2=$2 # 9090 ...
- [原创]java WEB学习笔记40:简单标签概述(背景,使用一个标签,标签库的API,SimpleTag接口,创建一个自定义的标签的步骤 和简单实践)
本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...
- Python 3 socket 编程
Python 3 socket编程 一 客户端/服务器架构 互联网中处处是C/S架构 1.C/S结构,即Client/Server(客户端/服务器)结构 2.在互联网中处处可见c/s架构 比如说浏览器 ...
- python内置方法补充bin
bin(x) 英文说明:Convert an integer number to a binary string. The result is a valid Python expression. I ...
- <Linux内核源码>文件系统VFS内核4.0.4版本基本概念源码
题外话:Linux内核从2.x和3.x到现在最新的4.x变化非常大,最直观的表现就是很多书上的内核代码已经无法直接继续使用,所以看看新的源码是非常有意义的! (下文中的内核源码都来自于 kernel ...
- Java JDK环境配置及说明
一.Java程序运行机制 Java语言编写的程序需要经过编译生成与平台无关的字节码(.class文件). 这种字节码必须使用Java解释器(JVM)来解释执行. JVM是可运行Java字节码文件的虚拟 ...
- ubuntu commands mysql
use table; //选择某个表 show tables; //展现有几个表 select * from table; //显示表内容
- Win7远程桌面_ZC01
1.Win7的远程桌面,在一开始设置成全屏显示,当远程桌面窗口 切换为非全屏的状态时,要想再切换成全屏状态 就比较困难了(我的笔记本ThinkpadE440一直没有弄成功...) 1.1.网上搜索各种 ...