These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: how to change used database at runtime
PostPosted: Tue Oct 31, 2006 3:54 pm 
Newbie

Joined: Tue Oct 31, 2006 3:45 pm
Posts: 1
Hi all;
I am new about hibernate. And I wanto learn, is ti possible change used db(mayde dialect and driver class properties) at runtime? İf so, could you give me an example?
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 02, 2006 5:02 am 
Newbie

Joined: Tue Oct 11, 2005 4:46 am
Posts: 3
Location: Germany/Dörverden
Hi,

you can set a new hibernate.cfg.xml File with this Method in the HibernateSessionFactory.java

/**
* return session factory
*
* session factory will be rebuilded in the next call
*/
public static void setConfigFile(String configFile) {
HibernateSessionFactory.configFile = configFile;
sessionFactory = null;
}

The Parameter is the Path to the Configurationfile

e.g.: "/path/to/hibernate/NEWhibernate.cfg.xml"

After this, you have a new session, when you connect over a DAO Object to the Database.

By


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.