File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Midlets and Database

 
Rob Levo
Ranch Hand
Posts: 167
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 167
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does MIDP support JDBC or is database programming on handheld devices use something else.
Still need help on this topic.
Thanks
 
gold feng
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can handle the database by the servlet.
 
Rob Levo
Ranch Hand
Posts: 167
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am talking about the database on the PDA itself.
 
Mark Herschberg
Sheriff
Posts: 6037
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 167
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic