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>
  • 相关阅读:
    centos6升级python
    MySQL的BLOB类型(解决mysql不支持mb4编码的时候存储emoji表情问题)
    librdkafka安装和php扩展php-rdkafka安装
    Mac High Sierra 降级安装Mac Sierra
    mysql常用命令
    PHP_CodeSniffer 安装和phpstorm配置
    SSH登录异常(someone is doing something nasty)
    java并发 —— Lock
    java 并发——线程
    java 并发——内置锁
  • 原文地址:https://www.cnblogs.com/sharpest/p/6118246.html
Copyright © 2011-2022 走看看