This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Midlets and Database  RSS feed

 
Ranch Hand
Posts: 167
  • 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
  • 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
 
Greenhorn
Posts: 5
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am talking about the database on the PDA itself.
 
Sheriff
Posts: 6037
  • 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
 
Greenhorn
Posts: 2
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • 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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!