Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DAO pattern

 
Stephen Harris
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone have any information/white papers on how Exceptions are excepted to be handled in the context of the DAO pattern described here:
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
They simply ignore the area of Exceptions.
I specifically was looking at abstract Factory approach and how an Exception that is indigenous to a particular datasource; e.g., SQLException, LdapException, IOException, etc would be cast/mapped to the abstract interface's signature (e.g., CustomerDAO.insertCustomer() throws DAOException).
After reading through their text and examples, it seems like they either except you to throw java.lang.Exception (rather than your own package-specific subclassed Exception), or they pretend that you throw now exception at all. I know this was probably done for simplicity, but it shows only part of the picture.
Wonder if the exam assumes such simplicity.
Thanks! I hope this was somewhat clear.
 
Lionel Port
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the prefered method is to wrap the implementation specific exception into your own custom exception.
 
Lionel Port
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
btw your DAOException class must at least have the following constructor.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic