Click here to load reader
Upload
muthusvm
View
1.239
Download
1
Embed Size (px)
DESCRIPTION
Session11 J2ME Record Management System Database
Citation preview
Outline-session 11 (20-April-2009)
>> J2ME Record Management System-Notification of Changes with Record Listener-Exception Handling
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.
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.
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);
Sample program
>>RMSListener.java
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
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()
Exception Handling
>> RecordStoreException-- A general exception indicating an error with the record store.
>> public RecordStoreException()>>public RecordStoreException(String message)
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)
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)
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)