Hibernate入门:第一个hibernate程序
来源:互联网 发布:行业大数据平台 编辑:程序博客网 时间:2024/05/18 02:11
虽然了简单的一个入门程序,但是还是出现了不少错误,纠结了一整天,终于将问题一一解决。
问题一:
Configuration config = new Configuration();出错,找不到配置文件,无法初始化,检查配置文件hibernate.cfg内容和目录位置都没错;
在网上找了许多相关错误解决方案,都无果,最后见到一篇文章,说是不使用系统库的hibernate库,自己添加hibernate的jar包,尝试了一下,问题解决了!
问题二:
SessionFactory sessionFactory = config.configure().buildSessionFactory( new ServiceRegistryBuilder().buildServiceRegistry());出错,
出现以下异常:
WARN: HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
Exception in thread "main" org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
检查hibernate.cfg.xml文件无错,有配置dialect,后来在src目录下添加hibernate.properties配置文件,内容如下:
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.password=634587
hibernate.connection.url=jdbc:mysql://localhost:3306/test
hibernate.connection.username=root
hibernate.dialect=org.hibernate.dialect.MySQLDialect
就可解决问题!
- Hibernate入门02 - 第一个Hibernate程序
- Hibernate入门02 - 第一个Hibernate程序
- Hibernate入门02 - 第一个Hibernate程序
- Hibernate入门:第一个hibernate程序
- Hibernate入门配置--第一个Hibernate程序
- Hibernate 入门的第一个程序
- Hibernate入门之第一个程序
- 第一个 Hibernate 程序(入门详解)
- Hibernate:第一个Hibernate程序
- Hibernate 第一个hibernate程序
- 第一个Hibernate程序
- 第一个hibernate程序
- hibernate第一个程序
- 第一个hibernate程序
- 第一个hibernate程序
- 第一个Hibernate程序
- 第一个Hibernate程序
- 第一个Hibernate程序
- 伯克利DB
- Oracle 的NVL
- 第八周实验报告(一)《方案一》用类的重载运算符 +、-、*、/,使之能用于复数的加减乘除
- How to Sign Android APK or Zip Files
- MD5加密安全?
- Hibernate入门:第一个hibernate程序
- How to Create Android Update Zip Package
- virtualPT, 一个IEC61850抓包工具
- WinForm中Application.Exit与Environment.Exit的区别
- Android消息处理机制:Handler Thread Message Looper
- java使用iText生成pdf文档的对齐方式
- how to compile kernel
- std:string学习
- spring管理hibernate事务报异常--Transaction not successfully started解决方法