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 ...
随机推荐
- 每天一个Linux命令(22)find命令_命令详解
find命令的一些常用参数的常用实例和用时的注意事项. 实例: (1)-name参数: 1)[sunjimeng@localhost home]$ find ~ -name & ...
- 每天一个Linux命令(16)which命令
which命令用于查找并显示给定命令的绝对路径. 环境变量PATH中保存了查找命令时需要遍历的目录.which指令会在环境变量$PATH设置的目录里查找符合条件的文件.也就是说,使用which命令,就 ...
- UITableViewCell高度自适应的关键点
iOS开发中对于UITableViewCell高度自适应的文章已经很多很多,但如果cell内容比较复杂,刚使用autolayout配置自使用时还是总不能一次性成功. KEY POINT 这里只说设置的 ...
- 总结最近写的h5项目
其实最近最大的感触就是真正独立完结一个项目的人学到的东西是最多,但并不意味着自己已全部吸收,还是得消化消化 最近做了一个移动端的h5页面,感兴趣的可以访问看一看:http://app.500jia.c ...
- 普林斯顿算法(1.3)并查集(union-find算法)——本质就是一个数 下面的子树代表了连在一起的点
转自:https://libhappy.com/2016/03/algs-1.3/ 假设在互联网中有两台计算机需要互相通信,那么该怎么确定它们之间是否已经连接起来还是需要架设新的线路连接这两台计算机. ...
- JavaUtil_09_email_使用 commons-email 发送邮件
二.参考资料 1.[commons]邮件发送工具——commons-email
- Git之Eclipse提交项目到Github并实现多人协作
一.Eclipece提交项目到Github 见 eclipse提交项目到github 二.利用github组织实现多人协作 1.新建组织: New organization
- hibernate复习第(一)天
首先导入jar. 这个版本是3.2.5 开发流程: 1.由Domain object ->mapping ->db (官方推荐) 2.由DB开始,使用工具生成mapping和Domain ...
- java--Hibernate实现分页查询
首先在Action类定义当前页的值 private Integer currPage = 1 setter,getter 在spring IOC容器进行注入该变量 在Action类写一个findAll ...
- Struts2 - 通过实现 Aware 接口访问 Web 资源
Action 类通过可以实现某些特定的接口, 让 Struts2 框架在运行时向 Action 实例注入 parameters, request, session 和 application 对应的 ...