This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Best Practices - Exception Handling Mechanism Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Best Practices - Exception Handling Mechanism" Watch "Best Practices - Exception Handling Mechanism" New topic

Best Practices - Exception Handling Mechanism

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9344


I have a persistence layer which looks up a JNDI datasource and executes the SQL queries. So in effect, all the persistence methods that I have should handle NamingException and SQLException. Now what would be the best practice to the caller which is usually my middle tier to handle such exceptions? or do I handle them in my persistence layer and throw another generic exception to my service?

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
David Newton

Joined: Sep 29, 2008
Posts: 12617

Personally, I'd throw some sort of persistence exception to the next layer up.
Don't get me started about those stupid light bulbs.
subject: Best Practices - Exception Handling Mechanism
Similar Threads
How to handle securityException in Service layer
how to use Struts and JDO
How to deal with transaction??
Tweaking tomcat 6 file
Terminology Clarification