aspose file tools*
The moose likes Servlets and the fly likes Opinion with db access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Opinion with db access" Watch "Opinion with db access" New topic
Author

Opinion with db access

Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
Hi everyone, I was wondering if it's better to have the jdbc code in the Controller or the Model? or does that even matter at all. Which is the standard practice amount you experienced programmers?

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

All DB access should be hidden behind the Model layer in my opinion.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
pravin kantipudi
Greenhorn

Joined: Mar 23, 2008
Posts: 5
all jdbc code should be in a DAO.Data Access Object pattern.

Your controller class should invoke model class which inturn should invoke DAO class to do all jdbc calls

hope this explains. Look at DAO pattern for more info
Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
Where can I find more DAO info? Can anyone of you provide me a link that I can do more research about it?


Thank you
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

http://en.wikipedia.org/wiki/Data_Access_Object
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Opinion with db access