• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OO Design issue with Data and RMI instance??

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following problems see below..
package suncertify.db;
import java.io.*;
import java.util.*;
import java.rmi.*;
public interface DataClient extends Remote
{
public FieldInfo [] getFieldInfo()throws RemoteException;
public DataInfo getRecord(int recNum)throws DatabaseException, RemoteException;
public DataInfo find(String toMatch)throws DatabaseException, RemoteException;
public void add(String [] newData)throws DatabaseException, RemoteException;
public void modify(DataInfo newData)throws DatabaseException, RemoteException;
public void delete(DataInfo toDelete)throws DatabaseException, RemoteException;
public void close() throws RemoteException;
public void lock(int record)throws IOException, RemoteException;
public void unlock(int record)throws RemoteException;
public DataInfo[] criteriaFind(String criteria) throws DatabaseException, RemoteException;
public String[] getComboValues(int fieldNum) throws DatabaseException, RemoteException;
public int getMatchCount(String matchCount) throws DatabaseException,RemoteException;
}

package suncertify.db;
import java.io.*;
import java.util.*;
public class DataClientLocal implements DataClient
{
public DataClientLocal(String dbname){
try
{
Data dbInstance = new Data(dbname);
}
catch(Exception ex)
{
System.out.println("Database connection failed");
}
}
}
//next code>DataClientRMI
package suncertify.db;
import java.io.*;
import java.util.*;
import java.rmi.*;
public class DataClientRMI implements DataClient
{
public DataClientRMI(){
try
{
////////
}
catch(Exception ex)
{
System.out.println("Database connection failed");
}
}
}

then on the client:::::
public switchMode
{
DataClient data =null;
if(localmode)
{
data = new DataClientLocal(arg1,...)
}
else
{
data = new DataClientRMI(arg1,...)
}
}
Problem is when I try to compile these above classes::
DataClientRMI
DataClientLocal
//I get the errors these two classes must be declared abstract but if I do this I cant create an instance of these 2 classes in myabove switchMode().
Any suggestions or solutions for my code.Perhaps I am missing something here???
Thanks Lisa

 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you implement all methods in in the interface ? If you did not implement all methods in an interface your class implemented, you will get such error message you had.
 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you implemented all methods in the interface ? If you did not implement all methods in the interface, you will get such error message when you compile your class.

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You must implement all your classes. Take a carefull look to your class implmentations again
------------------
------------------------
Koray G��l�
(B.s. Computer Engineer)
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am assuming that you intentionally do not want to implement all the methods that you have defined in your interface. One solution is to go back and implement all the methods of the interface. The other solution is to define an Adapter class. This class implements the interface and has empty implements for each. You can then subclass that adapter and define only those methods that you want. So first decide whether you want to implement all the methods or not.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic