使用hibernate出错了!

ITdavid 2006-03-09 11:58:56
我在使用myeclipse的hibernate功能时,在一个测试Test.java文件中写到:

Session session = (Session) HibernateSessionFactory.currentSession();//报错
Transaction transaction = session.beginTransaction();
transaction.commit();
HibernateSessionFactory.closeSession();

而HibernateSessionFactory类中的:

private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";
private static final Configuration cfg = new Configuration();
...
cfg.configure(CONFIG_FILE_LOCATION);
sessionFactory = cfg.buildSessionFactory();//报错

他们的错误是:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.HibernateException: database product name cannot be null
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:374)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:110)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)
at hb.Test.main(Test.java:25)

上面两处出错,是什么原因,是不是hibernate.cfg.xml的问题?
...全文
31 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
ITdavid 2006-03-10
up
回复
CristinNa 2006-03-10
上面的log4j不是错误,而是警告,是因为log4j没有配置,这是无关紧要的,与Hibernate无关
是hibernate.cfg.xml的问题
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2006-03-09 11:58
社区公告
暂无公告