This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Servlets and the fly likes Opinion with db access Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply 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: 56554
    
  14

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


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About 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: 56554
    
  14

http://en.wikipedia.org/wiki/Data_Access_Object
 
jQuery in Action, 2nd edition
 
subject: Opinion with db access