Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceE...

Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Cannot open connection

检查一下 数据源 配置, 看你的异常应该是 使用 JTA 事物 ,容器没有实例化 EntityManager 

 1 <?xml version="1.0"?>
 2 <persistence xmlns="http://java.sun.com/xml/ns/persistence"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
 5     http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
 6   <persistence-unit name="jun" transaction-type="RESOURCE_LOCAL">
 7       <provider>org.hibernate.ejb.HibernatePersistence</provider>
 8     <properties>
 9          <property name="hibernate.dialect" 
10              value="org.hibernate.dialect.MySQLDialect"/><!--数据库方言-->
11          <property name="hibernate.connection.driver_class" 
12              value="com.mysql.jdbc.Driver"/><!--数据库驱动类-->
13          <property name="hibernate.connection.username" value=""/><!--数据库用户名-->
14          <property name="hibernate.connection.password" value=""/>
15          <property name="hibernate.connection.url" 
16              value="jdbc:mysql://localhost:3306/mytest;"/><!--数据库连接URL-->
17          <property name="hibernate.max_fetch_depth" value="3"/><!--外连接抓取树的最大深度 -->
18          <property name="hibernate.hbm2ddl.auto" value="update"/><!-- 自动输出schema创建DDL语句 -->
19          <property name="hibernate.jdbc.fetch_size" value="18"/><!-- JDBC的获取量大小 -->
20          <property name="hibernate.jdbc.batch_size" value="10"/><!-- 开启Hibernate使用JDBC2的批量更新功能  -->
21          <property name="hibernate.show_sql" value="true"/><!-- 在控制台输出SQL语句 -->
22       </properties>
23   </persistence-unit>
24 </persistence>

 

转载于:https://www.cnblogs.com/sharpest/p/6118246.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值