Hibernate错误之org.hibernate.HibernateException : 'hibernate.dialect' must be set when no Conne
来源:互联网 发布:管理顾客的软件 编辑:程序博客网 时间:2024/04/28 08:59
org.hibernate.HibernateException : 'hibernate.dialect' must be set when no Connection available
at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:106)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:152)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833)
at org.hibernate.cfg.Configuration.buildSettings( Configuration.java:2829)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
at com.hibernate.helloapp01.BusinessServise.<clinit>(BusinessServise.java:21)
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available
at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:106)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:152)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833)
at org.hibernate.cfg.Configuration.buildSettings( Configuration.java:2829)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
at com.hibernate.helloapp01.BusinessServise.<clinit>(BusinessServise.java:21)
编程时出现这种错误的原因如下:
1、最明显的原因,在配置文件中没有设置Dialect;
2、第二个原因,和编程时采用哪种配置文件有关系,hibernate有两种配置文件:一种是XML格式的,另一种是*.properties文件格式,你可以采用这两种配置文件中的任意一种,但是要注意的是在编写代码时是有区别的
在java业务层代码中,
Configuration config = new Configuration();
config. addClass(Customer.class);
原因就在于上面要你注意的红色代码,当我们采用XML文件作为配置文件的时候,定义Configuration对象是不能采用这种形式的,应该改为如下形式:
Configuration cfg=new Configuration().configure();
将该代码改了之后再运行,一切OK。反之,如果你采用properties格式的文件,那么代码就应该不用改动了。建议使用XML文件,比较规范,便于阅读和管理。
0 0
- Hibernate错误之org.hibernate.HibernateException : 'hibernate.dialect' must be set when no Conne
- Exception in thread "main" org.hibernate.HibernateException: 'hibernate.dialect' must be set when no
- 异常:org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available
- ssh整合Caused by: org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection
- org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available
- HibernateException: 'hibernate.dialect' must be set when no Connection available
- hibernate.dialect' must be set when no Connection available错误
- hibernate.dialect' must be set when no Connection available错误
- hibernate.dialect' must be set when no Connection available错误
- 搭建hibernate时 'hibernate.dialect' must be set when no Connection available错误
- hibernate第二篇 org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' no
- 'hibernate.dialect' must be set when no Connection available
- 'hibernate.dialect' must be set when no Connection available
- 'hibernate.dialect' must be set when no Connection avalable
- “org.hibernate.HibernateException: Hibernate Dialect must be explicitly set” 异常解决
- org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set 解决方法
- org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
- org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set .
- 兼容ie8-解析数组时个数的错误
- 标定相机参数
- 打造atom成为golang开发神器
- jQuery UI datepicker
- 高斯混合模型Gaussian mixture model(GMM)
- Hibernate错误之org.hibernate.HibernateException : 'hibernate.dialect' must be set when no Conne
- 下面程序的功能是在屏幕上显示图形:
- 使用ScheduledExecutorService周期性的定时任务
- 前端开发入门:前端开发基础成长指南
- ViBE算法分析
- Java学习笔记(5):1.类和对象
- K-means算法
- jsp程序设计-Tag文件与Tag标记用法详解
- 类封装成dll