• 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

NX: used RMI & Local in local Side

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry , i think the question is very old, but
I found and look a lot of topics in javaranch.
But i still unstand.
in my document :
Required Interface
Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:
package suncertify.db;
public interface DBAccess
{
// Reads a record from the file. Returns an array where each
// element is a record value.
public String [] readRecord(long recNo)
throws RecordNotFoundException;
// Modifies the fields of a record. The new value for field n
// appears in data[n]. Throws SecurityException
// if the record is locked with a cookie other than lockCookie.
public void updateRecord(long recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException;
// Deletes a record, making the record number and associated disk
// storage available for reuse.
// Throws SecurityException if the record is locked with a cookie
// other than lockCookie.
public void deleteRecord(long recNo, long lockCookie)
throws RecordNotFoundException, SecurityException;
// Returns an array of record numbers that match the specified
// criteria. Field n in the database file is described by
// criteria[n]. A null value in criteria[n] matches any field
// value. A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)
public long[] findByCriteria(String[] criteria);
// Creates a new record in the database (possibly reusing a
// deleted entry). Inserts the given data, and returns the record
// number of the new record.
public long createRecord(String [] data)
throws DuplicateKeyException;
// Locks a record so that it can only be updated or deleted by this client.
// Returned value is a cookie that must be used when the record is unlocked,
// updated, or deleted. If the specified record is already locked by a different
// client, the current thread gives up the CPU and consumes no CPU cycles until
// the record is unlocked.
public long lockRecord(long recNo)
throws RecordNotFoundException;
// Releases the lock on a record. Cookie must be the cookie
// returned when the record was locked; otherwise throws SecurityException.
public void unlock(long recNo, long cookie)
throws SecurityException;
}
i think Sun says the class cannot be modi by myself.
someone say create a top abstract class and
two dbaccess ,one is local and other is a
remote;
can you give me a example? please help me!!!
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gy
I disagree with having Data an abstract class. Your instructions tell you that Data must implement the DBAccess interface. This doesnt sound abstract to me.
Once you have Data implemented, then you can look at how to connect to it in local or networked mode.
I am unsure of what your question was asking. Were you asking for help with the Data class? Or were you asking about the local / networked modes?
Regards, Andrew
 
guyue0505
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My question is about lcoal and Remote Mode
I think for some days about Design:
1) I create a class Data.java which implemts the DBAccess interface .
public class Data{
public readRecord(long recNo)
throws RecordNotFoundException{
//read record from the .db file
}
.....
}
2) i create a interface RemoteDBAccess.java
import java.rmi.*;
public interface RemoteDBAccess extends Remote{
public String [] readRecord(long recNo)
throws RecordNotFoundException,RemoteException;
....
}
I also create a class RemoteData.java
import java.rmi.*;
import java.rmi.server.*;
/**
*This is the implements from RemoteDBAccess used for Remote mode
*@date 2003-05-18
*@author Steven Gu
*/

public class RemoteData
extends UnicastRemoteObject
implements RemoteDBAccess{

public RemoteData () throws RemoteException{
super();
}
public String [] readRecord(long recNo)
throws
RecorNotFoundException ,
RemoteException{
//some codes :.....
}
}
can you tell me Am i right?
Thank you very much
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gy,
This looks like a very reasonable start to me.
Changing topic, is your name really Steven? If so, how do you feel about changing your name (here) to meet the JavaRanch registered names policy.
Regards, Andrew
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Andrew, How do you know his name is really Steven? That was a good pull.
Ok let me edit my post here now that I figured out how Andrew knew Gy's name is Steven.
So now Steven you just need to include your last name to be following the Naming Policy.
Mark
[ June 18, 2003: Message edited by: Mark Spritzler ]
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Steven, you have a duplicate thread. There are two threads by you that are on the exact same topic. Which one do you want closed, because I can't figure out which one is more up to date, has your answer.
If you could do me a favor and pick which one of the two you want to keep, and then delete the other, I would greatly appreciate it.
Thanks
Mark
 
guyue0505
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this topic is not ;
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This thread appears to be the duplicate of this thread.
I am going to close the other thread.
Mark
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Steven, please review JavaRanch's Naming Policy, and change your name accordingly. To be more specific you have to add a last or family name.
Thanks,
-Barry
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So from what I understand, you end up running methods on different interfaces depending on whether its a local or network connection, right?
DBAccess for LOCAL and RemoteDBAccess for NETWORK, right?
Does this fit with the requirements?
Sanjay

Originally posted by Andrew Monkhouse:
Hi Gy,
This looks like a very reasonable start to me.
Changing topic, is your name really Steven? If so, how do you feel about changing your name (here) to meet the JavaRanch registered names policy.
Regards, Andrew

 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well actually different implementations of the interface. There is only one interface, but you will have two classes that implement it.
Does that help?
Mark
[ January 27, 2004: Message edited by: Mark Spritzler ]
 
amchi gelo
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a little confused now... isnt it more like two interfaces RemoteDBAccess and DBAccess which are similar but not exactly the same. And two different classes which implement them?
So when its in the Network mode, it runs RemoteDBAccess and not DBAccess methods...?

Originally posted by Mark Spritzler:
Well actually different implementations of the interface. There is only one interface, but you will have two classes that implement it.
Does that help?
Mark
[ January 27, 2004: Message edited by: Mark Spritzler ]

 
Hey, I'm supposed to be the guide! Wait up! No fair! You have the tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic