zoukankan      html  css  js  c++  java
  • Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set

    docs.jboss.org文档示例代码:(http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/

    1     static {
    2         try {
    3             sessionFactory = new AnnotationConfiguration()
    4                     .configure().buildSessionFactory();
    5         } catch (Throwable ex) {
    6             // Log exception!
    7             throw new ExceptionInInitializerError(ex);
    8         }
    9     }

    测试时出现Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set

    自己依赖的是hibernate-core-4.2.7.Final.jar

    改成:

    1 Configuration cfg = new Configuration().configure();  
    2 ServiceRegistry serviceRegistry= new ServiceRegistryBuilder().applySettings(cfg.getProperties()).buildServiceRegistry();  
    3 sessionFactory = cfg.buildSessionFactory(serviceRegistry);  

    Hibernate官网上没找到说明。网上找的。

  • 相关阅读:
    Vue生命周期总结
    jQuery的层级选择器
    jQuery操作DOM的相关方法
    PHP基本语法
    组件间的传值
    MV*模式
    js 常用事件
    kali使用-WIFI破解
    使用css将网页变成黑白色
    css权重等级
  • 原文地址:https://www.cnblogs.com/xiluhua/p/4358335.html
Copyright © 2011-2022 走看看