File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java Micro Edition and the fly likes how can I have a database in J2ME, since there is no SQL??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "how can I have a database in J2ME, since there is no SQL???" Watch "how can I have a database in J2ME, since there is no SQL???" New topic

how can I have a database in J2ME, since there is no SQL???

Roberto Rangel

Joined: Nov 01, 2007
Posts: 1
Hey guys,

I need to create a RELATIONAL database in J2ME but I was told there is no SQL in J2ME and that I should use XML to store data. Is this the best way? I need to store the data in the device, so it doesn't connect to any server or anything like that.

Does anybody know how to do this?

Much appreciated,
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

You were told wrong. I'm pretty sure that there's a version of IBM's DB2 UDB that's specifically designed for mobile devices. Nor is it the only SQL DBMS for mobiles. There's also a number of non-SQL DBMS's suitable for lightweight systems if you don't need the full feature set of SQL.

An IDE is no substitute for an Intelligent Developer.
ramzi ghaith

Joined: Apr 03, 2007
Posts: 12
i think that you can use the Records Store in
javax.microedition.rms.RecordStore package

example: RecordStore.openRecordStore("Database Name",true);

then you can add new records on the records store.

for more info see :
Sukitha R Udugamasooriya

Joined: Jul 27, 2007
Posts: 14
Yeah as Ramzi told you can use Records Store for the persistence storage for mobile devices. And it is very easy. But since your requirement is to have "relational characteristics" to your database, Tim's suggestions are very good. But still it depends on your requirement.
All the best
3 cheers JavaRanch

Sukitha Udugamsooriya<br />(SCJP,SCMAD,SCWCD,(SCBCD-final touch))
Albert Kam
Ranch Hand

Joined: Oct 18, 2007
Posts: 58
Yes, i understand the difficulty in finding the j2me database solutions. I've found out what works best now for my CDC app, which is the Apache Derby. As far as i can see, it's free and it works :-)

It can be embedded and supports CDC profile.

EmbeddedSimpleDataSource is Derby's DataSource implementation for J2ME/CDC/Foundation. It is also supports J2SE platforms. Supports the same properties as EmbeddedDataSource, see that class for details.

EmbeddedSimpleDataSource automatically supports the correct JDBC specification version for the Java Virtual Machine's environment.

* JDBC Optional Package for CDC/Foundation Profile(JSR-169) - J2ME - CDC/Foundation

Quoted from this page

Also, i found out about JDBM which stores java objects and have the atomic transaction feature. I read others say about hsqldb that works great (although i ended up with failures when trying hsqldb with IBM J9)

Anyway, please share other solutions which works for you :-)

Albert Kam

Be nice !
I agree. Here's the link:
subject: how can I have a database in J2ME, since there is no SQL???
It's not a secret anymore!