AccessDatabase is a LANDP client that accesses any LANDP Shared File Database. It demonstrates running the shared file in online mode, retrieving database information, and performing several record level tasks, including retrieval, searching, locking, updating and addition.
The client also uses some Supervisor wrapper methods, including the standard functions to connect and disconnect from LANDP.
To run AccessDatabase, the sample client application, you need to customise a Shared File server called SHFILE01, using a Shared File server called SHFILE01. The vectors you should add to the COMMON.SPC are shown below:
RECDEF |
NAME=LDPREC01, DELIMIT='/', DECSEP=',' |
RECFIELD   |
NAME=NAMES, LENGTH=20, FORMAT=C |
RECFIELD |
NAME=NUMBP, LENGTH=12, FORMAT=N |
RECFIELD |
NAME=BALS, LENGTH=12, FORMAT=P |
SHFLDBD |
SHFLPRF=LDPDATA, DBDNAME=LDPDBD, RECNAME=LDPREC01, KEY01=(NUMBP,P,N,,), KEY02=(NAMES,S,N,,), KEY03=(BALS,S,N,,), DBDPATH=C:\LDP\SHFL\, DBFLNAME=LDPDATA |
SHFLPCB |
PCBNAME=ACCNUMB, KEYFIELD=NUMBP |
SHFLPCB |
PCBNAME=ACCNAME, KEYFIELD=NAMES |
SHFLPCB |
PCBNAME=BALANCE, KEYFIELD=BALS |
To define your workgroup, create a directory in EHCCUS called LDPJAVA, and create a LANCONF.SPC file containing the following definitions:
LANCONF   |
NAME=LDPJAVA, WSNAMES=(SF), DEFAULTS=GENERAL |
LWSCONF |
NAME=SF, TYPE=NT, SERVER=JAVA, PAR&JAVA=(Y), SERVER=(SHFILE01), PAR&SHFL=(LDPDATA,,3), CLIENT=(SHFILE01,SF) |
Validate and distribute the files for workstation SF as normal, and copy the "landpjava" package from the tutorials directory to the workstation directory.
Start LANDP, making sure you first create the Shared File log, and compile the samples with the following command:
You can now start the sample application with the following command:
Having registered with the Java manager, the RemoteRequest object which is returned is used as a parameter to create new instances of the Supervisor and Shared File Server classes.
The Supervisor server is needed for the connect() function to connect to LANDP services. The application then reads in the users input for a Shared File server to connect to. It then attempts to connect to this server using the start() method of the SharedFileServer class, which if successful, creates a new SharedFileSession object, and initialises it with all the available Shared Files belonging to that database. All the information for each Shared File is stored in a Shared File class, with the key name of the class (PCB Name in LANDP) used as the key to retrieve that Shared File.
The user is prompted for a key to use from the list of available keys. Information about the Shared File relating to that key is then displayed, followed by the first record in the Shared File with this key.
The user is then prompted for a record number to retrieve, and this is displayed using the getRecord method of the SharedFile class, with the record number as a parameter.
The application now starts a transaction to begin an update procedure on a record. It calls the startTransaction() method of the SharedFileSession class.
The user is asked to enter a search string, to find a record using the current key that matches the search string. This record is then locked for update using the lockRecord method of the SharedFile class, with the search string as a parameter. The user is now prompted to enter the updated data, and this record is replaced with the replaceRecord method with the data as a single parameter, replacing the data in the locked record.
Within the same transaction, the user is prompted to add data for a new record, which is inserted using the addRecord function. The transaction is then committed, with the commitTransaction function, before the transaction is closed, the session is closed, and the shared file server is stopped.
Finally the disconnect() method of the Supervisor class is called to close the connection with LANDP.
The source code for AccessDatabase is provided with this tutorial.