This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes suggestions for a Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "suggestions for a "user selectable database" design" Watch "suggestions for a "user selectable database" design" New topic
Author

suggestions for a "user selectable database" design

j po
Greenhorn

Joined: Aug 18, 2009
Posts: 2
Inherited a big jumbled, messy, old java application. Currently the app overview is like this:

-some Struts 2 that we added but, 75% old legacy stupidly written java that is total spaghetti and almost non-existent OO design implementation. (Don't even have a 'user' object for example)
-running on Tomcat 6 which handles the connection pooling
*upon login, the user selects the database out of a dropdown. his datasource, based upon user selection, is then passed around in every method signature all the way back to the DAO where it is then used. Don't even ask *why?*, let's just say...it's the government

All the designs I have previously worked on never had any kind of selectable database/datasource requirement like this. So, I'm looking for some design input on how this could be refactored in a more efficient/elegent way.

Let me know if more detail is needed. I appreciate in advance, everyone's time.

J
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
You could have init method that will set data source to every services that require data source.
When user login just call the init method.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
j po
Greenhorn

Joined: Aug 18, 2009
Posts: 2
thanks for the reply. Could you explain this a little more?

"set data source to every services that require data source".

It's just a ton of classes that have the need for the datasource. So, how do you get the datasource from the login (or init method, as you mentioned, to the back end dao's (and other legacy classes that hit the db)?

thanks again!
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
You could do something like:



I hope you get some idea.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: suggestions for a "user selectable database" design
 
Similar Threads
looking for suggestions on better DAO design
SP or Business Tier
passed SCJD with 360/400
Suggestions for displaying files from database
Synchronized display of volatile data.