suncertify.db
Class Data

This class provides the basic database services. It uses two
other support classes: DataInfo and FieldInfo.

Version:

1.0 07/31/1999

Constructor Summary

Data(java.lang.String dbname)
This constructor opens an existing database given the name
of the disk file containing it.

Data(java.lang.String dbname,
FieldInfo[] fields)
This constructor creates a new database file, using the name
provided for the disk file and using the FieldInfo array to
describe the field names and sizes that should be created.

Method Summary

void

add(java.lang.String[] newData)
This method adds a new record to the database.

void

close()
This method closes the database, flushing any outstanding
writes at the same time.

void

delete(DataInfo toDelete)
This method deletes the record referred to by the record
number in the DataInfo argument.

protected void

finalize()
The finalize method to close the underlying DataBase file when
DataBase is garbage collected.

find

This method searches the database for an entry which has a first
field which exactly matches the string supplied. If the required
record cannot be found, this method returns null. For this
assignment, the key field is the record number field.

add

This method adds a new record to the database. The array of
strings must have exactly the same number of elements as the
field count of the database schema, otherwise a RuntimeException
is issued. The first field, the key, must be unique in the
database or a RuntimeException is thrown.

Parameters:

newData - The elements of the record to add.

Throws:

DatabaseException - Attempted to add a duplicate key or
database file could not be accessed.

modify

This method updates the record specified by the record number
field in the DataInfo argument. The fields are all modified
to reflect the values in that argument. If the key field
specified in the argument matches any record other than the
one indicated by the record number of the argument, then a
RuntimeException is thrown.

lock

Lock the requested record. If the argument is -1, lock the whole
database. This method blocks until the lock succeeds. No timeouts
are defined for this.

Parameters:

recNum: - The record number to lock.

Throws:

DatabaseException: - If the record position is invalid.

unLock

public void unLock(int recNum,
java.lang.String clientID)

Unlock the requested record. Ignored if the clientID does not have
a current lock on the requested record.

Parameters:

recNum: - The record number to unLock.

Throws:

DatabaseException: - If the record position is invalid.

releaseLocks

public void releaseLocks(java.lang.String clientID)

The method to release all locks held by the ClientId which just got severed.
This calls the corresponding method of the underlying 'DbLockTable"
object of this DataBase.

Parameters:

clientID - : the id of the client whose connection just got severed.

releaseLocks

public void releaseLocks()

This method is use to clear all locks at time of bringing
down the database server and also when there are no client
references to the Remote Server. This calls the corresponding
method of the underlying "DbLockTable" object of this DataBase.