zoukankan      html  css  js  c++  java
  • 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 

     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>
  • 相关阅读:
    “TensorFlow 开发者出道计划”全攻略,玩转社区看这里!
    项目章程
    Android 开发环境的搭建(新环境)
    java中八种基本数据类型以及它们的封装类,String类型的一些理解
    一品黄山 天高云淡
    一品黄山 天高云淡
    黄山的日出日落
    宏村,寻找你的前世今生
    宏村,寻找你的前世今生
    git把本地文件上传到github上的步骤
  • 原文地址:https://www.cnblogs.com/sharpest/p/6118246.html
Copyright © 2011-2022 走看看