Meaningless Drivel is fun!
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Back again, About Exception Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Back again, About Exception Question" Watch "Back again, About Exception Question" New topic

Back again, About Exception Question

Jesse Xie Y.S.

Joined: Feb 09, 2004
Posts: 20
I prefer to implement a business logic layer between user client and database, and I am just confusing about how could I deal with so much exception. Should I ignore the IOException? Could I ignore the RemoteException? Or maybe I could just transform it into other exception such as RecordNotFoundException or RoomNotFoundException?

Any help. TKS very much.

Thomas Paul Bigbee
Ranch Hand

Joined: Jun 28, 2005
Posts: 71

The link above will take you to a good article on how to chain exceptions.

You can't ingnore Checked Exceptions, and you can't specify any new/broader exceptions when implementing an interface, you can however,chain exceptions (throw a RuntimeException) from within the IOException catch block, with the Cause and Stack information from the original exception, and handle it in the business tier

Hope this helps
Jesse Xie Y.S.

Joined: Feb 09, 2004
Posts: 20
Hi, good day every one. I really don't know how to deal with IOException.

public synchronized long[] findByCriteria(String[] criteria) {
long[] result;
... ...
return result;
} catch (IOException ioe) {
//If have exception return null;
return null;
//If have no result,return 0 length array
return new long[0];

how do you think?
Jesse Xie Y.S.

Joined: Feb 09, 2004
Posts: 20
Hi Thomas, after I read over this forum about the IOException, I found that it is really a big problem. and now, I want to try your suggestion.

So I just create a new DataException and extends from RuntimeException, and I will catch it on business layer.

I think it's normally a fetal error about reading file, because my program will make sure that the file exist before create new Data instance.
I agree. Here's the link:
subject: Back again, About Exception Question
It's not a secret anymore!