File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "Best Practices - Exception Handling Mechanism" Watch "Best Practices - Exception Handling Mechanism" New topic
Author

Best Practices - Exception Handling Mechanism

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Guys,

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, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Personally, I'd throw some sort of persistence exception to the next layer up.
 
I agree. Here's the link: http://aspose.com/file-tools
 
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 logging.properties file
Terminology Clarification