-->
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.  [ 1 post ] 
Author Message
 Post subject: Using more than one database in datasource
PostPosted: Thu Sep 21, 2006 12:03 pm 
Newbie

Joined: Fri Sep 15, 2006 4:40 pm
Posts: 4
In my project, I am using 2 databases (i.e DB1 and DB2) interchangeably. However, in my Tomcat datasource, I currently have one datasource setup


Tomcat server.xml

Code:
...
<Resource name="jdbc/DB" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/DB">
<parameter>
<name>url</name><value>jdbc:jtds:sqlserver://XXXXXX/DB1</value>             
</parameter>
...


hibernate.cfg.xml

Code:
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.connection.datasource">java:comp/env/jdbc/DB</property>
...


My question is: How do you tell Spring or Hibernate to delegate to the appropriate datasource given that I create another datasource name in Tomcat or hibernate config files?For example, class A is a DAO that access both databases (DB1 and DB2) and has 2 methods, getDataFromDB1() and getDataFromDB2(). How do you tell Spring or Hibernate to dispath datasource DB1 for method getDataFromDB1() and datasource DB2 for method getDataFromDB2()?


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

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.