session11 j2me record management system database

11

Click here to load reader

Upload: muthusvm

Post on 08-Jun-2015

1.239 views

Category:

Technology


1 download

DESCRIPTION

Session11 J2ME Record Management System Database

TRANSCRIPT

Page 1: Session11 J2ME Record Management System Database

Outline-session 11 (20-April-2009)

>> J2ME Record Management System-Notification of Changes with Record Listener-Exception Handling

Page 2: Session11 J2ME Record Management System Database

Record Listener>>Record Listener is a interface in

javax.microedition.rms package.>> we have to add the Record Listener implemented

class with Record store Class.>> Record listener has the three methods are

recordAdded(),recordChanged(),recordDeleted() >>All three methods will be called ,if any changes

occurred in record of the record store.

Page 3: Session11 J2ME Record Management System Database

Record Listener API

RecordListener Interface in javax.microedition.rms.RecordListener

Method Description

void recordAdded(RecordStore recordStore, int recordId)

Called when record is added

Void recordChanged(RecordStore rs,int recordid)

Called when record is Updated

Void recordDeleted(RecordStore rs,.int recordid)

Called when record is deleted.

Page 4: Session11 J2ME Record Management System Database

RecordListener Interface ImplementationClass RLAction implements RecordListenert{

public void recordAdded(RecordStore rs,int recordd){

System.out.println(“Record inserted”);}public void recordChanged(RecordStore rs, int recordid){

System.out.println(“Record Chanage”);}public void recordDeleted(RecordStore rs, inr recordid){

System,.out.println(“Record deleted”);}

}RLAction rl =new RLAction()); RescordStore rsss=new RecordStore(“test”,true);rss.addRecordListener(rl);

Page 5: Session11 J2ME Record Management System Database

Sample program

>>RMSListener.java

Page 6: Session11 J2ME Record Management System Database

Exception Handling

>>There are five exception that are specific to the RMS.>>All Exception are inherited from java.lanag.Throwable class.>>Exception are

1. InvalidRecordIDException2. RecordStoreException3. RecordStoreFullException4. RecordStoreNotFoundException5. RecordStoreNotOpenException

Page 7: Session11 J2ME Record Management System Database

Exception Handling

>> InvalidRecordIDException-- Used to indicate an invalid record number-- if RecordStore.getRecord(int) is called with a record that does not exist in the record store, this exception will be thrown

>>public InvalidRecordIDException(String message)>>public InvalidRecordIDException()

Page 8: Session11 J2ME Record Management System Database

Exception Handling

>> RecordStoreException-- A general exception indicating an error with the record store.

>> public RecordStoreException()>>public RecordStoreException(String message)

Page 9: Session11 J2ME Record Management System Database

Exception Handling

>> RecordStoreFullException-- Signals the record store is full-- if RecordStore.add Record(byte[], int, int) is called to add a new record, this exception will be thrown if the record store has reached its maximum capacity

public RecordStoreFullException()public RecordStoreFullException(String message)

Page 10: Session11 J2ME Record Management System Database

Exception Handling

>> RecordStoreNotFoundException-- Indicates the record store name does not exist-- calling RecordStore.deleteRecordStore(String) with an invalid record store name will result in this exception being thrown

>> public RecordStoreNotFoundException()>>public RecordStoreNotFoundException(String message)

Page 11: Session11 J2ME Record Management System Database

Exception Handling

>> RecordStoreNotOpenException-- Used to indicate that the requested record store is not open.-- For example, if RecordStore.getNumRecords() is called prior to opening the record store, this exception will be thrown.

>>public RecordStoreNotOpenException()>>public RecordStoreNotFoundOpen(String message)