"Introduction to Java Mobile/PDA Programming" Reading notes 11--MIDP database design 1

Source: Internet
Author: User
Tags version
Notes | program | design | data | database | Database design
JDBC is designed for desktop platforms or enterprise users and is not suitable for mobile communication devices.

MIDP provides a record-oriented database (record orieted db) for permanent data storage, known as the Records Management system recording Management systems (RMS)

All classes related to records management systems are placed in the Javax.microedition.rms package, including: A class: RecordStore four interfaces: Recorcomparatorrecordenumerationrecordfilterrecorlistener five An exception: Invalidrecordidexceptionrecordstoreexceptionrecordstorefullexceptionrecordstorenotfoundexceptionrecordstorenotopenexc Eption

The general database management system holds a table (table) and records storage (record store) in the record management system.

Record storage full name (up to 32 Unicode characters, case-sensitive): MIDlet Suite name + supplier name + record warehousing name on the actual device, a MIDlet suite full name: MIDlet Suite name + supplier name + version number that MIDlet Suite-name+midlet-vendor+midlet-version

If you think of records warehousing as a form, then this table has only two fields (Column) One is the record ID, the other is the data

The RecordStore class represents unique record warehousing. We use the RecordStore class to provide the Openrecordstore () to open the record warehousing, this is a static factory method design pattern. Instead of creating a RecordStore object through new.

Openrecordstore () constructor 4 parameter: Record the warehouse name Boolean value, True indicates that the open record does not exist is to allow the system to establish a new data warehouse false does not exist when thrown Recordstorenotfoundexecption exception authentication mode, Acceptance: record.authmode_private--only the MIDlet suite that establishes this record warehouse can access this record warehouse, record.authmode_any--any midlet on the device can use read record warehousing. Boolean value, whether other midlet on the device can write data to this record warehouse. Other MIDlet to record storage: The third parameter determines the read right, and the fourth parameter determines the write right

If the memory is not sufficient to open, throw recordstorefullexception

3 parameter: Record warehousing name MIDlet Suite Supplier name authentication mode, record.authmode_private--to establish record warehousing midlet and the MIDlet currently calling it must belong to a MIDlet suite, otherwise throw SecurityException; record.authmode_any--any midlet can call this method.

2 parameter: Record warehouse name Boolean value, True indicates that the open record does not exist is to let the system establish a new data warehouse false does not exist when thrown recordstorenotfoundexecption exception

SetMode () method to change authentication mode, and other MIDlet suite MIDlet write Rights listrecordstores () get the name of all the records warehousing in the MIDlet suite where the current MIDlet resides

After using the record warehousing, you must use Closerecordstore () closed record storage to release the system resources, all recordlistener are emptied, related recordenumeration. If it is closed, throw the recordstroenotopenexception.

Deleterecordstore () Delete record warehousing. If this record warehouse is being occupied, throw recordstorenotfoundexception

Record warehousing information: Name: Record warehousing name timestamp-long type: Last Change of Time (System.currenttimemills () obtained) version number: Initially 0, each change plus 1Next record ID: initially 1, Add a new record plus 1 each

Getlastmodified () Obtain a time stamp getname () Obtain the name of the Record store Getnextrecordid () Obtain the value of the next recording ID getnumrecords () Obtain the number of pens recorded in the warehouse () GetSize () Obtain the space occupied in the record Storage getsizeavailable () The remaining space getversion () Obtain the record storage version number


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.