aspose file tools*
The moose likes Java Micro Edition and the fly likes Midlets and Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Midlets and Database" Watch "Midlets and Database" New topic

Midlets and Database

Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
How do I use a database in a Midlet program?
Can somebody provide some general info or some links that will help me get started?
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
Does MIDP support JDBC or is database programming on handheld devices use something else.
Still need help on this topic.
gold feng

Joined: Sep 25, 2001
Posts: 5
You can handle the database by the servlet.
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
I am talking about the database on the PDA itself.
Mark Herschberg

Joined: Dec 04, 2000
Posts: 6037
There is no JDBC support in MIDP/CLDC. Technically, there isn't file IO support either, because we can't assume all devices will support "files."
MIDP does support RMS. You cn use this API to store persistent data. The MIDP provider will have insured that the RMS APIs will integrate seamlessly (well, in theory, anyway), with whatever persistent storage the device's native OS supports.
Robert Hendry

Joined: Oct 19, 2001
Posts: 2
I have been able to write MIDlets that use a db. Look up the RecordStore class. This class maps DIRECTLY to a palm DB.
For example if you have a Java RecordStore named "mystuff", a palm db will be created as "mystuff.pdb". When you hot sync, the mystuff.pdb file will be automatically transferred to the host.
Here is some example code the will write a record to a RecordStore
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeUTF("Bob Hendry");
byte[] b = baos.toByteArray();
db.addRecord(b, 0, b.length);
t.insert("Record Inserted",0);
catch(Exception e){
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Well, rms seems to work Ok as long as you create the 'database' on PDA (in other words as long as you use to store some intermediate data). However I am wondering, what to do if you already have a database full of data (let's say you want to implement a dictionary) that you want to install as part of the application and use by your code.
You certainly can install a pdb file on Palm (I am mainly interested in Palm right now) however I can not figure out how do you open this PDB file. Neither RecordStore.openRecordStore nor listRecordStores do not seem to do the trick.
I have tried to make part of the jar file (Converter does not seem to pick it up), install it independently etc. but nothing seems to work :-(((
Any advice?
By the way, this ranch was a cool idea :-))
I agree. Here's the link:
subject: Midlets and Database
Similar Threads
Quick question on data structure used in JMS APIs
Establishing a remote database
How to get the all results using HQL
share data
How to calculate the hit count