SlideShare una empresa de Scribd logo
1 de 21
Outline-session 9 (09-April-2009)
>> J2ME Record Management System
-Introduction
-RMS
-Record Store
-Record Store-MIDlet
-Record Store –Scope
-Record Store –Two attribute
-Record Store –API
-Record Enumeration
Introduction
• Just like ordinary desktop-based programs, MIDlets need a
facility to store data permanently.
• Cell phones and other mobile devices are quite limited when
compared to desktop systems.
• NO file system nor relational database in a MIDP-based
environment.
• MIDP provides the persistence storage package
javax.microedition.rms for storing data.
• The package is called Record Management System (RMS)
provides a simple record-oriented database.
RMS(Record Management System)
•
•
•
•

RMS is a system for managing records.
A record is an individual data item.
No data type. A record is represented by an array of bytes.
A record can contain a number, a string, an array, an image -anything that a sequence of bytes can represent.
• Manipulating byte array is difficult.
• A simple way is to use String as it has a rich API to manipulate
and convert it to and from byte array is simple.
Where are the fields?
• Don't be confused by the term record. The answer is simple:
– In RMS a record doesn't have any fields.
• A record consists of an array of single binary field of variable
size identified by a record Id.
• This keeps RMS small and flexible -- important attributes for a
MIDP subsystem.
• The programmer has to handle type conversion, comparison,
etc.
Record Stores
• A record store is an ordered collection of records.
• Each record must belong to a record store, and all record
access occurs through the record store.
• In fact, the record store guarantees that records are read and
written atomically, with no possibility of data corruption.
Record Stores
• When a record is created, the record store assigns it a unique
identifier, an integer called the record ID.

• The first record added to a record store has a record ID of 1,
the second a record ID of 2, and so on.
Record Stores-MIDlet
• A MIDlet can have any number of record stores (including
none)
• Each record store is uniquely identified by its name
• MIDlet is part of MIDlet suite, record store names must also
be unique within the suite
• MIDlets that are packaged within a suite can access not only
the record stores they create, but also those of other MIDlets
in the suite
Record Stores-Scope
• Within "MIDlet Suite One," MIDlet #1 and MIDlet #2 can
access all four record stores available as part of the suite.
• MIDlets in Suite One cannot access the record stores of Suite
Two.
Record Stores-Two attribute
>> There are two values maintained by a record store that may
be helpful for tracking database usage
1. Version Number:
–
–
–
–

Version number is an integer value.
the starting value when creating a new record is not defined by the
API
If you need to track version numbers, you can query the
record store immediately after creation using getVersion() to
determine the starting value.

1. Date and Timestamp:
–
–

is a long integer that represents the number of milliseconds since
midnight January 1st, 1970. You can query this value by calling
getLastModified().
Record Store API
>>This class is the heart of the RMS. Through this class we create, update,
query and delete record stores
Record Store API
>>This class is the heart of the RMS. Through this class we create, update,
query and delete record stores
Manage Record Store
•

•
•

•

To open a record store, you simply need to call the openRecordStore
method.
– public static RecordStore openRecordStore(
String recordStoreName,
boolean createIfNecessary)
throws RecordStoreException, RecordStoreFullException,
RecordStoreNotFoundException
createIfNecessary determines whether the record store, if not existed, will
be created or a RecordStoreNotFoundException will be thrown.
The following opens a record store named "Address."
RecordStore rs = RecordStore.openRecordStore("Address",
true);
The record store will be created if it does not exist.
Manage Record Store
•
•

closeRecordStore() method closes an open record.
rs.closeRecordStore();
Remember to clean up after yourself as much as possible.

•

To delete a record store and its contained records, call the static
deleteRecordStore() method.
RecordStore.deleteRecordStore("Address");

•

To find out all the record stores available to a particular MIDlet suite, call
the listRecordStores() method:
public static String[] listRecordStores()
Adding records
• The MIDlet invokes the addRecord() method
of RecordStore class to insert a new record
into the record store.
– public int addRecord(byte[] data, int offset, int numBytes)
inserts a record represented by an array of bytes data with offset as
its starting index and numBytes as its length.

String brand = "Honda";
byte bytes[] = brand.getBytes();
int recID = rs.addRecord(bytes,0,bytes.length);
Manage Record Store
•
•

closeRecordStore() method closes an open record.
rs.closeRecordStore();
Remember to clean up after yourself as much as possible.

•

To delete a record store and its contained records, call the static
deleteRecordStore() method.
RecordStore.deleteRecordStore("Address");

•

To find out all the record stores available to a particular MIDlet suite, call
the listRecordStores() method:
public static String[] listRecordStores()
Retrieving Record
• There are two versions to retrieve a record:
public int getRecord(int recordId, byte[] buffer, int offset)
– copies the data stored in the given record to the byte array
represented by buffer.
public byte[] getRecord(int recordId)
– returns a new copy of the data represented by recordId.

byte[] retrieved = new byte[rs.getRecordSize(recID)];
rs.getRecord(id, retrieved, 0);
String retrievedString = new String(retrieved);
byte[] retrieved = rs.getRecord(recID);
String retrievedString = new String(retrieved);
Update Record
• To update a record use the method
setRecord:
public void setRecord(int recordId,
byte[] newData, int offset, int numBytes)
– sets new information, a stream of bytes (newData) with offset as its
starting index and numBytes as its length, at the record location
represented by recordId.

String brand = "Toyota";
byte data[] = newappt.getBytes();
rs.setRecord(recID, data, 0, data.length());
Deleting Record
• The MIDlet invokes the deleteRecord()
method to delete a record from the record
store.
public void deleteRecord(int recordId)
– deletes the record represented by recordId. The
recordId is not reused.
rs.deleteRecord(1);
Record Enumeration
•

The RecordEnumeration (A.K.A enumerator) class provides methods for
moving forward and back through a record store.
• you might prefer to enumerate through the records, sorting alphabetically
Enumeration Implementation
RecordEnumeration re = rs.enumerateRecords(null,null,false);
while (re.hasNextElement())
{
// Get the next record into a String
String str = new String(re.nextRecord());
... do something ...
}
Record Enumeration
•

Key Methods in enumeration
>> nextRecord() to move forward
>>previousRecord() to move back
>>previousRecord(), whichh will return the last record
• An enumerator maintains in internal index of the record store
1. You can make calls to reindex() whenever you update, delete or add a
record.
2. A record listener can be established to notify you of changes to the record
store
3. Whenever a change occurs, the listener will call one of three methods,
depending on whether the change was an add, delete or update
Record Enumeration-API

Más contenido relacionado

Similar a Recordmanagment

Happy To Use SIMD
Happy To Use SIMDHappy To Use SIMD
Happy To Use SIMDWei-Ta Wang
 
MariaDB ColumnStore
MariaDB ColumnStoreMariaDB ColumnStore
MariaDB ColumnStoreMariaDB plc
 
Oracle training-in-hyderabad
Oracle training-in-hyderabadOracle training-in-hyderabad
Oracle training-in-hyderabadsreehari orienit
 
Why databases cry at night
Why databases cry at nightWhy databases cry at night
Why databases cry at nightMichael Yarichuk
 
Clustered Columnstore - Deep Dive
Clustered Columnstore - Deep DiveClustered Columnstore - Deep Dive
Clustered Columnstore - Deep DiveNiko Neugebauer
 
Star schema my sql
Star schema   my sqlStar schema   my sql
Star schema my sqldeathsubte
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and ArchitectureVinit Raut
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkarRavi Shankar
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkarDhaval Shukla
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkarManzoor ALam
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkarMurali Krishna
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkarSAQUIB AHMAD
 
Configuring workload-based storage and topologies
Configuring workload-based storage and topologiesConfiguring workload-based storage and topologies
Configuring workload-based storage and topologiesMariaDB plc
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkarjemimajerome
 
In memory databases presentation
In memory databases presentationIn memory databases presentation
In memory databases presentationMichael Keane
 
05 integrate redis
05 integrate redis05 integrate redis
05 integrate redisErhwen Kuo
 

Similar a Recordmanagment (20)

Happy To Use SIMD
Happy To Use SIMDHappy To Use SIMD
Happy To Use SIMD
 
MariaDB ColumnStore
MariaDB ColumnStoreMariaDB ColumnStore
MariaDB ColumnStore
 
Oracle training-in-hyderabad
Oracle training-in-hyderabadOracle training-in-hyderabad
Oracle training-in-hyderabad
 
Why databases cry at night
Why databases cry at nightWhy databases cry at night
Why databases cry at night
 
Clustered Columnstore - Deep Dive
Clustered Columnstore - Deep DiveClustered Columnstore - Deep Dive
Clustered Columnstore - Deep Dive
 
Redis overview
Redis overviewRedis overview
Redis overview
 
Star schema my sql
Star schema   my sqlStar schema   my sql
Star schema my sql
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkar
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkar
 
8085 micro processor book
8085 micro processor book8085 micro processor book
8085 micro processor book
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkar
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkar
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkar
 
J2ME RMS
J2ME RMSJ2ME RMS
J2ME RMS
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Configuring workload-based storage and topologies
Configuring workload-based storage and topologiesConfiguring workload-based storage and topologies
Configuring workload-based storage and topologies
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkar
 
In memory databases presentation
In memory databases presentationIn memory databases presentation
In memory databases presentation
 
05 integrate redis
05 integrate redis05 integrate redis
05 integrate redis
 

Más de myrajendra (20)

Fundamentals
FundamentalsFundamentals
Fundamentals
 
Data type
Data typeData type
Data type
 
Hibernate example1
Hibernate example1Hibernate example1
Hibernate example1
 
Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
 
2 jdbc drivers
2 jdbc drivers2 jdbc drivers
2 jdbc drivers
 
3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
 
Dao example
Dao exampleDao example
Dao example
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
Internal
InternalInternal
Internal
 
3. elements
3. elements3. elements
3. elements
 
2. attributes
2. attributes2. attributes
2. attributes
 
1 introduction to html
1 introduction to html1 introduction to html
1 introduction to html
 
Headings
HeadingsHeadings
Headings
 
Forms
FormsForms
Forms
 
Css
CssCss
Css
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Starting jdbc
Starting jdbcStarting jdbc
Starting jdbc
 

Último

FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 

Último (20)

FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 

Recordmanagment

  • 1. Outline-session 9 (09-April-2009) >> J2ME Record Management System -Introduction -RMS -Record Store -Record Store-MIDlet -Record Store –Scope -Record Store –Two attribute -Record Store –API -Record Enumeration
  • 2. Introduction • Just like ordinary desktop-based programs, MIDlets need a facility to store data permanently. • Cell phones and other mobile devices are quite limited when compared to desktop systems. • NO file system nor relational database in a MIDP-based environment. • MIDP provides the persistence storage package javax.microedition.rms for storing data. • The package is called Record Management System (RMS) provides a simple record-oriented database.
  • 3. RMS(Record Management System) • • • • RMS is a system for managing records. A record is an individual data item. No data type. A record is represented by an array of bytes. A record can contain a number, a string, an array, an image -anything that a sequence of bytes can represent. • Manipulating byte array is difficult. • A simple way is to use String as it has a rich API to manipulate and convert it to and from byte array is simple.
  • 4. Where are the fields? • Don't be confused by the term record. The answer is simple: – In RMS a record doesn't have any fields. • A record consists of an array of single binary field of variable size identified by a record Id. • This keeps RMS small and flexible -- important attributes for a MIDP subsystem. • The programmer has to handle type conversion, comparison, etc.
  • 5. Record Stores • A record store is an ordered collection of records. • Each record must belong to a record store, and all record access occurs through the record store. • In fact, the record store guarantees that records are read and written atomically, with no possibility of data corruption.
  • 6. Record Stores • When a record is created, the record store assigns it a unique identifier, an integer called the record ID. • The first record added to a record store has a record ID of 1, the second a record ID of 2, and so on.
  • 7. Record Stores-MIDlet • A MIDlet can have any number of record stores (including none) • Each record store is uniquely identified by its name • MIDlet is part of MIDlet suite, record store names must also be unique within the suite • MIDlets that are packaged within a suite can access not only the record stores they create, but also those of other MIDlets in the suite
  • 8. Record Stores-Scope • Within "MIDlet Suite One," MIDlet #1 and MIDlet #2 can access all four record stores available as part of the suite. • MIDlets in Suite One cannot access the record stores of Suite Two.
  • 9. Record Stores-Two attribute >> There are two values maintained by a record store that may be helpful for tracking database usage 1. Version Number: – – – – Version number is an integer value. the starting value when creating a new record is not defined by the API If you need to track version numbers, you can query the record store immediately after creation using getVersion() to determine the starting value. 1. Date and Timestamp: – – is a long integer that represents the number of milliseconds since midnight January 1st, 1970. You can query this value by calling getLastModified().
  • 10. Record Store API >>This class is the heart of the RMS. Through this class we create, update, query and delete record stores
  • 11. Record Store API >>This class is the heart of the RMS. Through this class we create, update, query and delete record stores
  • 12. Manage Record Store • • • • To open a record store, you simply need to call the openRecordStore method. – public static RecordStore openRecordStore( String recordStoreName, boolean createIfNecessary) throws RecordStoreException, RecordStoreFullException, RecordStoreNotFoundException createIfNecessary determines whether the record store, if not existed, will be created or a RecordStoreNotFoundException will be thrown. The following opens a record store named "Address." RecordStore rs = RecordStore.openRecordStore("Address", true); The record store will be created if it does not exist.
  • 13. Manage Record Store • • closeRecordStore() method closes an open record. rs.closeRecordStore(); Remember to clean up after yourself as much as possible. • To delete a record store and its contained records, call the static deleteRecordStore() method. RecordStore.deleteRecordStore("Address"); • To find out all the record stores available to a particular MIDlet suite, call the listRecordStores() method: public static String[] listRecordStores()
  • 14. Adding records • The MIDlet invokes the addRecord() method of RecordStore class to insert a new record into the record store. – public int addRecord(byte[] data, int offset, int numBytes) inserts a record represented by an array of bytes data with offset as its starting index and numBytes as its length. String brand = "Honda"; byte bytes[] = brand.getBytes(); int recID = rs.addRecord(bytes,0,bytes.length);
  • 15. Manage Record Store • • closeRecordStore() method closes an open record. rs.closeRecordStore(); Remember to clean up after yourself as much as possible. • To delete a record store and its contained records, call the static deleteRecordStore() method. RecordStore.deleteRecordStore("Address"); • To find out all the record stores available to a particular MIDlet suite, call the listRecordStores() method: public static String[] listRecordStores()
  • 16. Retrieving Record • There are two versions to retrieve a record: public int getRecord(int recordId, byte[] buffer, int offset) – copies the data stored in the given record to the byte array represented by buffer. public byte[] getRecord(int recordId) – returns a new copy of the data represented by recordId. byte[] retrieved = new byte[rs.getRecordSize(recID)]; rs.getRecord(id, retrieved, 0); String retrievedString = new String(retrieved); byte[] retrieved = rs.getRecord(recID); String retrievedString = new String(retrieved);
  • 17. Update Record • To update a record use the method setRecord: public void setRecord(int recordId, byte[] newData, int offset, int numBytes) – sets new information, a stream of bytes (newData) with offset as its starting index and numBytes as its length, at the record location represented by recordId. String brand = "Toyota"; byte data[] = newappt.getBytes(); rs.setRecord(recID, data, 0, data.length());
  • 18. Deleting Record • The MIDlet invokes the deleteRecord() method to delete a record from the record store. public void deleteRecord(int recordId) – deletes the record represented by recordId. The recordId is not reused. rs.deleteRecord(1);
  • 19. Record Enumeration • The RecordEnumeration (A.K.A enumerator) class provides methods for moving forward and back through a record store. • you might prefer to enumerate through the records, sorting alphabetically Enumeration Implementation RecordEnumeration re = rs.enumerateRecords(null,null,false); while (re.hasNextElement()) { // Get the next record into a String String str = new String(re.nextRecord()); ... do something ... }
  • 20. Record Enumeration • Key Methods in enumeration >> nextRecord() to move forward >>previousRecord() to move back >>previousRecord(), whichh will return the last record • An enumerator maintains in internal index of the record store 1. You can make calls to reindex() whenever you update, delete or add a record. 2. A record listener can be established to notify you of changes to the record store 3. Whenever a change occurs, the listener will call one of three methods, depending on whether the change was an add, delete or update