Announcement Announcement Module
No announcement yet.
Using 2 or more databases Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using 2 or more databases

    I have a databases which references rows to another database. Using them both in transactions and such is easy. The ugly part is displaying data from both databases. Currently I have to create a 'Helper' bean which can hold the merged data from both databases.

    While this works, its kind of ugly since I can't use an O/R mapping. Does anyone have any other suggestions besides creating a Helper bean and merging the data?


  • #2
    If your database is Oracle, you can use DBLinks from db1 to db2. The application can then talk to db1.


    • #3
      This thread discusses an approach for accessing two or more independent data sources in one application. In summary, you can create a BeanFactory per unique data source.
      Last edited by robyn; May 19th, 2006, 05:31 AM.


      • #4
        Hmm that gives me an idea...

        I can inject Database1's DAO into a Bean of Database2

        Then in the bean of DB2 I can just do getBeanOfDB1 (accessing DB1's DAO) and this will make everything work transparently.

        Although this breaks a lot of rules since there is a DAO being used inside a bean.

        Or maybe I can do something aspect oriented, when getBeanOfDB1 is called have an interceptor inject the bean into the current DB2's bean.