This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Servlets and the fly likes What is the need for creating a Exception for  DAO Layer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "What is the need for creating a Exception for  DAO Layer" Watch "What is the need for creating a Exception for  DAO Layer" New topic
Author

What is the need for creating a Exception for DAO Layer

PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
What is the need for creating a Exception for DAO Layer like in this code below :




Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
135

To tell you something went wrong in the database layer? Can you expand on your doubt?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
Jeanne Boyarsky wrote: Can you expand on your doubt?


Jeanne thanks for the reply, My doubt is that

DAOException is a Checked or a RuntimeException ? and how the client (Servlet) should handle this ??
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
It is not necessarily to be called "DAOException". It is just a homegrown class which you use to hide the specific exceptions of the wrapped database communication API, like JDBC or Hibernate. If you already have the class, just check if it extends Exception or RuntimeException, then the remaining is fairly self-explaining.

Also see this article: http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html (do not only scan the code/article, but also read the text).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the need for creating a Exception for DAO Layer
 
Similar Threads
DAO Pattern
How to pass the DTO to the dao implementention layer
Business layer
Understanding DI
exception handling approach for j2ee web apps