• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding DataSource for Hibernate when Tomcat already startup.

 
Vo Hien
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My project uses Hibernate to lookup datasource. The datasource name is in the hibernate.cfg.xml file.

The rule of my web app is that the datasource info will be written in to the server.xml file after Tomcat 5.5 already startup. I follow the rule but when I start up Tomcat 5.5, it has an error because Hibernate Configuration needs a datasource name when Tomcat startup.

My questiion is:
Are there any ways to use Hibernate with a Datasource info added to the server.xml file when Tomcat 5.5 already startup.
Do you have any solution for this.

Thank you in advance !
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always create your SessionFactory through Code. Basically everything that could be in a hibernate.cfg.xml for a SessionFactory has an equivalent Java object, so that you can build up your SessionFactory from code.

Please read this chapter as it explains it all.
http://www.hibernate.org/hib_docs/reference/en/html/session-configuration.html

Good Luck

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic