It's not a secret anymore!
The moose likes OO, Patterns, UML and Refactoring and the fly likes Which J2EE Pattern(s) we must used? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Which J2EE Pattern(s) we must used?" Watch "Which J2EE Pattern(s) we must used?" New topic

Which J2EE Pattern(s) we must used?

jai walia

Joined: Jun 24, 2008
Posts: 4
Hi Ranchers,
My team is planning to develop an order management application for a specific domain. Here we have our own database(Oracle) for the data capturing purpose. Currently we are planning to use DAO,TO and Singleton pattern (plus other as progresses). But during analysis we got to know that we have to pick certain data from other database (MySQL) in a order entry form at run time against a business key. So here, we are expecting 2 database connection (Using JNDI), one (Oracle) for the whole application and second (MySQL) for one time, at the time of order entry.

So, My query how to intermingle with DAO pattern (if possible) with 2 connections, or will it require some other pattern?
Waiting for your reply....

Thanks,<br />jai_walia
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Your implementation of the Data Access Object design pattern will need to be able to handle communication with two databases. Whenever your business object communicated with a DAO, it will need to indicate which database it should work with. This can be done via method signature in the DAO call.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Just create one DAO instance for one DB and another DAO instance for another DB.

If this doesn't fit in your current DAO design, then it might be plain flawed. To start, only the word 'singleton' in combination with 'DAO' already doesn't sound very good.
Jelle Klap

Joined: Mar 10, 2008
Posts: 1924

You could combine the basic DAO pattern with the abstract factory pattern, as suggested by the DAO entry in the Core J2EE Pattern Catalog.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
I agree. Here's the link:
subject: Which J2EE Pattern(s) we must used?
jQuery in Action, 3rd edition