File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Real Time Scenario For  Singleton Desgnpatter and DAO design pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Real Time Scenario For  Singleton Desgnpatter and DAO design pattern" Watch "Real Time Scenario For  Singleton Desgnpatter and DAO design pattern" New topic
Author

Real Time Scenario For Singleton Desgnpatter and DAO design pattern

Deepak Sahu
Greenhorn

Joined: Dec 08, 2009
Posts: 19
Hi ,

Can someone please give me example of a real time scenario where Singleton Desgnpatter and DAO design pattern is used
damodar kumar
Ranch Hand

Joined: May 19, 2008
Posts: 77

Hi Deepak,

First i will go for Singleton

there is a funtionallity where you are getting Meta Data on to the form, so if you hit database for every time it is overhead to server. Instead get the data for first time and keep it in cache and use it for everytime untill the Meta data is not changed, if data is changed clear it and again get it from database.

Now DAO pattern

you have a application connecting to different databases like oracle,DB2and MSSQL etc
for the above you have get connections and do some stuff for persisting the data. So for all 4 database you will have to get the 4 connection object , it means there will be 4 classes for getting connection mechanism.
Instead doing such redendunt code, have a factory class , which will give you connection object depending upon database you using .

Damodar


<a href="http://stackoverflow.com/users/668970/user668970" rel="nofollow">
<img src="http://stackoverflow.com/users/flair/668970.png" >
</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Real Time Scenario For Singleton Desgnpatter and DAO design pattern