Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the need for creating a Exception for DAO Layer

 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the need for creating a Exception for DAO Layer like in this code below :




 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34371
345
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To tell you something went wrong in the database layer? Can you expand on your doubt?
 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic