Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Proper Application Design

Status
Not open for further replies.

chrisw09

IS-IT--Management
Nov 23, 2005
22
US
I'm trying to figure out the best way to go about developing an application that relies on 2 different datasources. One is mysql and the other is oracle. Currently i have a class, UserDAO that has the following methods:

Code:
getUserInfo() - gets info from mysql
getShipToList() - gets info from oracle

I'm not fond of this structure. I have them grouped together because the information each method retrieves is related to a User, yet they connect to 2 different databases. Chances are there will be a need to call getShipToList() from getUserInfo().

My question is, what is the best way of going about this? Do i leave it the way it is, or do i do something like create 2 separate classes like MysqlUserDAO and OracleUserDAO and then have a UserDAO that figures out where to go for the data i'm looking for?

Any suggestions would be most appreciated.
 
I'd keep the methods in the same class. They refer to the same logical entity (the user).

I'd do the diferentiation by using a getConnection method that accepts a parameter defining the implementation of the database.

Cheers,
Dian
 
Use pooling to do the underlying differences in db connection, leaving your business logic in the same class, as long as it applies. Just because two different datasources are used should not influence your class design.

Also, because JDBC 99% of the time database independant, naming your classes according to vendor is a mistake. Using pooling allows you to switch db vendors in the future without actual code change - making your code a little closer to the future proof goal.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top