• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

suggestions for a "user selectable database" design

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
j po
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could do something like:



I hope you get some idea.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic