Chapter 8. Database Programming

A database is a non-volatile place for storing the state of objects. For some applications, you might need objects to exist even after the application that created them closes. Without a storage mechanism, objects and their states are destroyed when an application closes. However, if you save objects to a persistent storage facility, such as a database, they can be read in later by the same application or even other applications.

The persistent storage facilities provided in the J2SE platform, such as the JDBC and Object Serialization APIs, are too large for handheld devices with a small memory footprint. Storage requirements vary significantly from one resource-constrained device to another. J2ME and the MIDP solve this problem by using the Record Management System (RMS).

This chapter introduces the details of the MIDP RMS, a persistent storage facility for MIDlets, and shows you how to develop MIDP database applications, using an example involving stocks. Throughout this chapter, the terms record store and database are used interchangeably.

The Record Management System

An RMS database (or record store) consists of a collection of records that remain persistent after the MIDlet closes. When you invoke the MIDlet again, it can retrieve data from the persistent record store. However, to use the RMS, we need to get familiar with some of the classes and concepts provided by the javax.microedition.rms package.

Record Stores

Record stores, which are ...

Get Wireless Java now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.