The problem is that your remote interface should let all method throw RemoteException. I have made an Adapter on the client, that chained all these RemoteException to the DatabaseException.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
I could not understand how to implement this. Could you give some basic sample code examples for local and remote data implmentation ?
Personally I like the idea of your interfaces throwing both IOException and DatabaseException. IOException is for your communication level exceptions,...
It is Ok, but there is no any communication level in local mode, so communication level exceptions. As you see above (in my samples) only remote mode can have communication problems and therefore RemoteException is defined.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
The advantage of having the one interface throwing IOException is that on the client side, you can map both the local and remote clients to the one interface. Which means you can have one single set of code for calling the database.
And if we were later to port the server to a J2EE server, then your scenario would port easier, since an EJB would need separate interfaces for local and remote access, and the local interface cannot throw communications exceptions.
Make a design decision. And document it
Hm, there some discussions in the forum where all agree. Is it good or bad?
![]()
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |