• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Configuration init error

 
Zhang Chenguang
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,everyone.

A problem in Hibernate configuration:

Always we config Hiberante by the config file "hibernate.cfg.xml".

But this time I want to config it in java class.

For example I create a project in Eclipse,and a class named MySessionFactory was created. In this class,I wrote:

Configuration cfg = new Configuration()
.addResource("com/lingdot/java/simplebbs/vo/User.hbm.xml")
.addResource("com/lingdot/java/simplebbs/vo/Topic.hbm.xml")
.addResource("com/lingdot/java/simplebbs/vo/Reply.hbm.xml")
.setProperty("connection.url",SystemConfig.getConfig("System.DataSource.url"))
.setProperty("connection.driver_class",SystemConfig.getConfig("System.DataSource.driver"))
.setProperty("connection.username",SystemConfig.getConfig("System.DataSource.username"))
.setProperty("connection.password",SystemConfig.getConfig("System.DataSource.password"))
.setProperty("dialect",SystemConfig.getConfig("System.DataSource.dialect"));


sessionFactory = cfg.buildSessionFactory();


Then I got a error:

database product name cannot be null.


Can someone help me? Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic