-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to define two datasource for any application
PostPosted: Fri Aug 26, 2005 7:57 am 
Newbie

Joined: Wed Aug 24, 2005 12:07 pm
Posts: 17
Hi Friends,
If I want to use two database in my application for e.g mySQL and MS-SQL Server then how can I define two datasource in the xml file.Do I have to make two hibernate.cfg.xml files or single file would be fine.If single file then how can I write both datasource in that file.I dont have any idea about this.Please let me know.All suggestions are welcome.
Thanx in Advance,
Chirag


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 26, 2005 8:36 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
You need two SessionFactories = two config files.


Top
 Profile  
 
 Post subject: Thanx but still have some doubt
PostPosted: Fri Aug 26, 2005 9:18 am 
Newbie

Joined: Wed Aug 24, 2005 12:07 pm
Posts: 17
Hi,
I agree of having 2 cfg files but then what name should be given to file and how can I decide which file to call when.I guess during SessionFactory.Please mention small code snippet if possible.
Thanx once again,
Chirag


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 26, 2005 9:24 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Configuration config1 = new Configuration();
config1.configure("fst_hibernate.cfg.xml");
SessionFactory sf1 = config1.buildSessionFactory();

Configuration config2 = new Configuration();
config2.configure("snd_hibernate.cfg.xml");
SessionFactory sf2 = config1.buildSessionFactory();

Both configs must be in classpath.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.