permaculture playing cards*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes [UB1.3.3] DBMain Question! Help me plz.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "[UB1.3.3] DBMain Question! Help me plz.." Watch "[UB1.3.3] DBMain Question! Help me plz.." New topic
Author

[UB1.3.3] DBMain Question! Help me plz..

Smith Jone
Greenhorn

Joined: Nov 15, 2006
Posts: 11
Following I implement Data Class.



Data implements DBMain,DBMainEx
If IOException isn't added on DBMainEx,I get a Complie failureoverridden method does not throw java.rmi.RemoteException
Because RemoteExcepion is subclass of IOException.
Do you Understand?


Origianlly, DBMain extended DBMainEx.And Class Data implements DBMainEx.


But,I changed for RemoteException(subclass of IOException).


Do I receive a cut in marks ? by marker
Is that Automatic Failures??


instructions.html
Any unimplemented exceptions in this interface must all be created as member classes of the suncertify.db package. Each must have a zero argument constructor and a second constructor that takes a String that serves as the exception's description.


[ November 20, 2006: Message edited by: Smith Jone ]

[ November 20, 2006: Message edited by: Smith Jone ]
[ November 20, 2006: Message edited by: Smith Jone ]

SCJP 5.0<br />SCJD(In progressing!)<br />SCWCD(planing)<br />SCBCD(planing)
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi

I am not shore what you try to do but take care the specification are clear :

Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:


It is true if you implements a sub interface you implements also its super interface. When you extend (or specialize) an interface you add new features but in your case the new features are the old one (only with an other flavor) and this is not so nice.

If you need to throw checkable exceptions you can :
1.Run in panic up and down
2.subclass the RecordNotFoundException
3.chain them in RunTimeException.
4.The same like 1 but now with a relaxed air.

Regards M
[ November 21, 2006: Message edited by: Mihai Radulescu ]

SCJP, SCJD, SCWCD, OCPJBCD
Smith Jone
Greenhorn

Joined: Nov 15, 2006
Posts: 11
If you need to throw checkable exceptions you can :
1.Run in panic up and down
2.subclass the RecordNotFoundException
3.chain them in RunTimeException.
4.The same like 1 but now with a relaxed air.



What is the "panic up and down & relawed air" ?? Could you explain it for me ?
If I have subclass the RecordNotFoundException,Can I declear the RemoteException on Remote Interface??

How chain them in RuntimeException ??
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi,

Ok, my mistake.After I read the post second time I get it, I was wrong.
What you need is an adapter which expose your bussines on the client. If you choose to use RMI you must throw only RemoteExceptions from each method.
If you need to transport other exceptions with the remote exception you can chain them(see the initCause method from the RemoteException). Is something like :
Client -> Adapter -> Data
Data -> RecordNotFoundException -> Adapter -> RemoteException(RecordNotFoundException)

I hope that now is clear. Sorry once more.

Regards M
[ November 21, 2006: Message edited by: Mihai Radulescu ]
Mark Smyth
Ranch Hand

Joined: Feb 04, 2004
Posts: 288
Originally posted by Mihai Radulescu:
Hi,

Ok, my mistake.After I read the post second time I get it, I was wrong.
What you need is an adapter which expose your bussines on the client. If you choose to use RMI you must throw only RemoteExceptions from each method.
If you need to transport other exceptions with the remote exception you can chain them(see the initCause method from the RemoteException). Is something like :
Client -> Adapter -> Data
Data -> RecordNotFoundException -> Adapter -> RemoteException(RecordNotFoundException)

I hope that now is clear. Sorry once more.

Regards M

[ November 21, 2006: Message edited by: Mihai Radulescu ]


There is nothing to stop you declaring other exceptions in the throws clause of a remote method declaration once one of those methods is a RemoteException.


From java.sun.com
An object becomes remote by implementing a remote interface, which has the following characteristics:

- A remote interface extends the interface java.rmi.Remote.

- Each method of the interface declares java.rmi.RemoteException in its throws clause, in addition to any application-specific exceptions.


But of course if you use the RemoteException to chain all other exceptions that occur in a method there is no need to declare any further exceptions in the method declaration.

Regards,
Mark

[ November 21, 2006: Message edited by: Mark Smyth ]
[ November 21, 2006: Message edited by: Mark Smyth ]

SCJP<br />SCJD
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Mark,


There is nothing to stop you declaring other exceptions in the throws clause of a remote method declaration once one of those methods is a RemoteException.

Your statement is true, generally, but I was strictly tacking about a particular case - the upper code snippet. There you can see that most of the methods throw RecordNotFoundException and IOException. The RecordNotFoundException is definitive not a RemoteException.

Regards,
the M.
Mark Smyth
Ranch Hand

Joined: Feb 04, 2004
Posts: 288
Originally posted by Mihai Radulescu:
Mark,


Your statement is true, generally, but I was strictly tacking about a particular case - the upper code snippet. There you can see that most of the methods throw RecordNotFoundException and IOException. The RecordNotFoundException is definitive not a RemoteException.

Regards,
the M.


Apologies I misunderstood your point. I take it what you meant was he should have his method signatures of the form:



rather than


If so we are in complete agreement.

Mark.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [UB1.3.3] DBMain Question! Help me plz..
 
Similar Threads
NX:About DBMain interface
Trying to instantiate my middle tier class??see code
Naming.Lookup and Rebind
OO Design issue with Data and RMI instance??
creating an Adapter for my interface??