问题太长 估计是她怕没有人愿意帮忙， 我这里也有 发出来 希望她不见怪
Your data access class must be called "Data.java", must be in a package called "s
uncertify.db", and must implement the following interface:
public interface DBAccess
// Reads a record from the file. Returns an array where each
// element is a record value.
public String  readRecord(long recNo)
// 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)
// 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)
// 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)
Any unimplemented exceptions in this interface must all be created as member clas
ses of the suncertify.db package. Each must have a zero argument constructor and
a second constructor that takes a String that serves as the exception's descripti
Any methods that throw RecordNotFoundException should do so if a specified record
does not exist or is marked as deleted in the database file.
Your choice of RMI or serialized objects will not affect your grade, but no other
approach is acceptable. In either case, the program must allow the user to speci
fy the location of the database, and it must also accept an indication that a loc
al database is to be used, in which case, the networking must be bypassed entirel
y. No authentication is required for database access.
Your server must be capable of handling multiple concurrent requests, and as part
of this capability, must provide locking functionality as specified in the inter
face provided above. You may assume that at any moment, at most one program is a
ccessing the database file; therefore your locking system only needs to be concer
ned with multiple concurrent clients of your server. Any attempt to lock a resou
rce that is already locked should cause the current thread to give up the CPU, co
nsuming no CPU cycles until the desired resource becomes available.
Data file Format
The format of data in the database file is as follows:
Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
4 byte numeric, total overall length in bytes of each record
2 byte numeric, number of fields in each record
Schema description section.
Repeated for each field in a record:
2 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
2 byte numeric, field length in bytes
end of repeating block
Repeat to end of file:
1 byte "deleted" flag. 0 implies valid record, 1 implies deleted record
Record containing fields in order specified in schema section, no separators betw
een fields, each field fixed length at maximum specified in schema information
End of file
All numeric values are stored in the header information use the formats of the Da
taInputStream and DataOutputStream classes. All text values, and all fields (whic
h are text only), contain only 8 bit characters, null terminated if less than the
maximum length for the field. The character encoding is 8 bit US ASCII.
The database that URLyBird uses contains the following fields: Field descriptive
name Database field name Field length Detailed description
Hotel Name name 64 The name of the hotel this vacancy record relates to
City location 64 The location of this hotel
Maximum occupancy of this room size 4 The maximum number of people permitted in t
his room, not including infants
Is the room smoking or non-smoking smoking 1 Flag indicating if smoking is permit
ted. Valid values are "Y" indicating a smoking room, and "N" indicating a non-smo
Price per night rate 8 Charge per night for the room. This field includes the cur
Date available date 10 The single night to which this record relates, format is y
Customer holding this record owner 8 The id value (an 8 digit number) of the cust
omer who has booked this. Note that for this application, you should assume that
customers and CSRs know their customer ids. The system you are writing does not i
nteract with these numbers, rather it simply records them. If this field is all b
lanks, the record is available for sale.
目前在Data file Format中的The format of data in the database file和Database schem
a之间的关系没搞懂，在db文件中似乎没有看到The format of data in the database file的
有什麽实质内容，让人费解（照理说应该是保存此db文件的信息）。在Data file Format中提