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

     static {
try {
sessionFactory = new AnnotationConfiguration()
.configure().buildSessionFactory();
} catch (Throwable ex) {
// Log exception!
throw new ExceptionInInitializerError(ex);
}
}

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

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

改成:

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

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

Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set的更多相关文章

  1. Connection cannot be null when 'hibernate.dialect' not set

    严重: Exception sending context initialized event to listener instance of class [org.springframework.w ...

  2. org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge]

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFacto ...

  3. Invocation of init method failed; nested exception is org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.impl

    严重: Exception sending context initialized event to listener instance of class org.springframework.we ...

  4. 正确决解Hibernate4.*中:Connection cannot be null when 'hibernate.dialect' not set

    <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hi ...

  5. Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFac

    警告: Exception encountered during context initialization - cancelling refresh attempt: org.springfram ...

  6. Hibernate(三): org.hibernate.HibernateException: No CurrentSessionContext configured!

    Hibernate版本5.2.9 获取Session的方式是sessionFactory.getCurrentSession(); 比较老一些的版本使用的是sessionFactory.openSes ...

  7. hibernate报错org.hibernate.HibernateException: No CurrentSessionContext configured!

    org.hibernate.HibernateException: No CurrentSessionContext configured! at org.hibernate.internal.Ses ...

  8. Caused by:org.hibernate.HibernateException:Unable to make JDBC Connection

    1.错误描述 Caused by:org.hibernate.HibernateException:Unable to make JDBC Connection[jdbc\:mysql\://loca ...

  9. Caused by: org.hibernate.HibernateException: identifier of an instance of ... is alterde from

    Caused by: org.hibernate.HibernateException: identifier of an instance of ... is alterde from     Hi ...

随机推荐

  1. 禁用LMHOSTS和NetBIOS后提升上网速度 ?

    LMHOSTS 文件是 windows 中进行 netbios 静态解析时使用的,其作用类型于 HOSTS 文件. 今天发现这个东西有点问题,在用ADSL上网时,明明 IP . DNS 都设置得好好的 ...

  2. [CC]CC插件初探

    应用程序插件框架的内容包括:主程序App,插件Plugin. 1.实现一个应用程序插架框架关键点有: 一个插件的标准接口,在主程序中存在一个插件的集合.主程序通过循环读取每个插件,将插件对象通过多态的 ...

  3. Hadoop学习笔记: HDFS

    注:该文内容部分来源于ChinaHadoop.cn上的hadoop视频教程. 一. HDFS概述 HDFS即Hadoop Distributed File System, 源于Google发表于200 ...

  4. How do you evaluate music?

    I’ve seen several “can’t stand” or “best of” threads in regard to music, and based on some related d ...

  5. Java Axis2 1.6.3+JDK1.7.0_13+Tomcat7.0.65+eclipse搭建web service

    安装文件下载: jdk1.7.0_13 安装步骤参考文章:http://jingyan.baidu.com/article/6dad5075d1dc40a123e36ea3.html tomcat7. ...

  6. iOS 判断字符串中含有某个字符串 rangeOfString

    //判断roadTitleLab.text 是否含有qingjoin if([roadTitleLab.text rangeOfString:@"qingjoin"].locati ...

  7. Sikuli增强包

    一.前提准备1)  VCForPython27.msi2)  Cython安装包3)  pyjnius安装包4)  sikuli_cpython安装包5)  SLF4J文件包二.安装过程1)  VCF ...

  8. Java基础(41):Java中集合中需要注意的几个要点(关于Collection与Map)

    同步性     Vector是同步的.这个类中的一些方法保证了Vector中的对象是线程安全的.而ArrayList则是异步的,因此ArrayList中的对象并 不是线程安全的.因为同步的要求会影响执 ...

  9. C++之路进阶——优先队列优化最短路径算法(dijkstra)

    一般的dijkstra算法利用贪心的思想,每次找出最短边,然后优化到其他点的的距离,我们还采用贪心思路,但在寻找最短边进行优化,之前是双重for循环,现在我们用优先队列来实现. 代码解释: //样例程 ...

  10. 夺命雷公狗---微信开发62----所以memcache对access_token进行全局缓存优化

    公众号调用接口并不是无限制的,为了防止公众号的程序错误而引发微信服务器负载异常,默认情况下, 每个公众号调用接口都不能超过一定限制,当超过一定限制时,调用对应接口会收到错误信息,造成调用失败. 我们也 ...