• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Adding DataSource for Hibernate when Tomcat already startup.

 
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 !
 
ranger
Posts: 17346
11
Mac IntelliJ IDE 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
    Bookmark Topic Watch Topic
  • New Topic