aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX:About DBMain interface 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 "NX:About DBMain interface" Watch "NX:About DBMain interface" New topic
Author

NX:About DBMain interface

xi ruo
Ranch Hand

Joined: Apr 06, 2003
Posts: 40
In my explainDocument for SCJD:
The data access class must implement the following interface:

This interface is implemented by my remote data access class which is "DatabaseImpl.java".
DatabaseImpl class implement java.rmi.Remote class,too.
So,these methods must throw the java.rmi.RemoteException for implement remote access.
Since these methods extend the DBMain interface,so may not throw the java.rmi.RemoteException?
Q:How do I do for the remote access?
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11509
    
  95

Hi Xi,
You may want to follow the links and discussion in this thread.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
xi ruo
Ranch Hand

Joined: Apr 06, 2003
Posts: 40
I do like this.Is it OK???

Data.java
Vlad Rabkin
Ranch Hand

Joined: Jul 07, 2003
Posts: 555
Hi Xi,
It will not work:
public class DataAdapter implement DBMain.
DataAdapter must implement another interface, whose method signatures throw either RemoteException or its parent Exceptions. This interface you should define yourself.
But the idea is correct...
Regards,
Vlad
Bharat Ruparel
Ranch Hand

Joined: Jul 30, 2003
Posts: 493
Hello Xi Ruo,
In addition to what Vlad says, you need to make sure that the Data class must implement DBMain.
Regards.
Bharat


SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA
xi ruo
Ranch Hand

Joined: Apr 06, 2003
Posts: 40
Andrew and Vlad and Bharat,thank you for your response.
I rework like this.

Data.java

AnotherDBMain.java

Is it OK?
Q:AnotherDBMain-interface's structure must the same as DBMain-interface's structure.Is it?
[ September 09, 2003: Message edited by: xi ruo ]
Vlad Rabkin
Ranch Hand

Joined: Jul 07, 2003
Posts: 555
Hi Xi,
It looks Ok.
Don't forget to implement also:
public int getRecordCount() throws RemoteException;//I add this extra method to AnotherDBMain interface
in your DataAdapter class.
Regards,
Vlad
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11509
    
  95

Hi Xi
Is it OK?

Looks OK.
Q:AnotherDBMain-interface's structure must the same as DBMain-interface's structure.Is it?

Not necessarily.
For the older Fly By Night Services assignment, you did have to provide networked versions of all the methods of the Data class. However there is no such requirement for the new assignments.
Some people here are only providing business methods over the network interface. Others are providing equivalent methods to all the methods detailed in the provided interface. I believe you may choose for yourself which you wish to do.
The advantage of your interface having the same methods as the provided interface is that you will be writing a generic database server. You will be able to use this with any database. Not just with Hotels or Contractors (whichever you have).
The advantage of only having business methods exposed to the clients is that you can save yourself some effort.
Personally I think that you should consider writing your interface so that it has the same methods as the provided interface. It is more extensible for the future, and it is more challenging.
Regards, Andrew
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX:About DBMain interface