wood burning stoves 2.0*
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
Author

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.
Thanks
gold feng
Greenhorn

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
Sheriff

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.
--Mark
Robert Hendry
Greenhorn

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
try{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeUTF("Bob Hendry");
dos.writeUTF(34);
dos.writeUTF("123.45");
byte[] b = baos.toByteArray();
db.addRecord(b, 0, b.length);
t.delete(0,t.size());
t.insert("Record Inserted",0);
}
catch(Exception e){
t.delete(0,t.size());
t.insert(e.getMessage(),0);
}
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
Thanks.
Anonymous
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 :-))
Petr
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Midlets and Database
 
Similar Threads
How to get the all results using HQL
Quick question on data structure used in JMS APIs
How to calculate the hit count
share data
Establishing a remote database