Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX:About DBMain interface

 
xi ruo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Xi,
You may want to follow the links and discussion in this thread.
Regards, Andrew
 
xi ruo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do like this.Is it OK???

Data.java
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 493
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Xi Ruo,
In addition to what Vlad says, you need to make sure that the Data class must implement DBMain.
Regards.
Bharat
 
xi ruo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 555
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic