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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

NX: used RMI & Local same Time in local Side

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!!
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Gy Gy:
I think that I have the same assignment as you (URLyBird). The way I interpretted SUN's directions in my class was:
Create a class, Data.java, that implements the DBAccess interface. This class must provide the basic data access functions. I surmise this class is possibly an "AUTOMATIC FAIL" if done improperly because SUN could well be running their test driver directly into it to evaluate your database design (i.e., locking).
Then create wrappers or callers for Data.java that handle the remote (RMI or sockets) feature. (My design has a DbServer class that is a Facade that wraps Data.java.)
Interestingly, the DBAccess interface doesn't follow SUN's documentation standards. I was conflicted whether it was OK to create a "clean" DBAccess interface file with proper javadoc, or just leave it ASIS.
Well, that's how I view the issue from Massachustts, other LAT/LONGs may differ ....
Tx
 
guyue0505
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Then create wrappers or callers for Data.java that handle the remote (RMI or sockets) feature. (My design has a DbServer class that is a Facade that wraps Data.java.)
please give me a example ,I am not unstand
 
Bob Reeves
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Gy Gy:
Simplified version:
class Data implements DBAccess {
public String [] readRecord(long recNo) {
...
}
}
class RemoteServer extends UnicastRemoteObject {
private Data myData = new Data();
public RecordModel readRecord(long recNo)
throws Remote {
String [] record = myData.recordRecord(recNo);
return new RecordModel(record);
}
...
}
So, RemoteServer is the remote rmi object, and passes its calls to Data. RecordModel is a great, programmer friendly enhancement. ) Seem OK?
Tx
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
    Bookmark Topic Watch Topic
  • New Topic