JavaDB on JavaME platform

As the consumer devices get more sophisticated, more complicated applications will run on devices and there will be greater need to manage the application data. The need for running database engine on small devices will thus be very critical.

JavaDB, a cost effective, easy to use, fully featured, pure Java database with a very small footprint (2MB), looks very promising  on small devices. I tried running it on the latest phoneME advanced (JavaME CDC) platform and could not resist the excitement of putting the details together in this blog. The procedure is very straight forward.

Prepare your setup as below, 

1. Get the latest phoneME advanced platform. Currently, it is supported only on Linux-x86 platform.
2. Get the latest JavaDB release.
3. You also need the JDBC Optional package library for CDC platform. It can be built from the source using the step by step instructions.

Now, try following on your linux box,

<CDC_HOME>/bin/cvm -Xbootclasspath/a:<JDBC_OP>/foundation_jdbc.jar 
-cp <JAVADB_HOME>/lib/derby.jar:<JAVADB_HOME>/lib/derbytools.jar
-Dij.dataSource=org.apache.derby.jdbc.EmbeddedSimpleDataSource
-Dij.dataSource.databaseName=sample
-Dij.dataSource.createDatabase=create
org.apache.derby.tools.ij

Note here that the JDBC Op package can also be built along with CDC binaries, as mentioned here. then, Xbootclasspath need not be specifed while running. By default, the CDC build does not include JDBC Op package, hence we include it in our example.

Please note that, JSR 169, The JDBC Optional package does not support java.sql.Driver. So, the 'ij' cannot be used in its typical form to connect to database via a JDBC driver. The connection in this case is established using the JDBC DataSource.

This will bring up the íj prompt. 'ij' provides Command Line Interface to interact with a database using SQL. You may create such connection directly from your ME application using DataSource objects. You can try some simple steps like below to further test this setup.

ij> create table t (id int not null, addr varchar(20));
0 rows inserted/updated/deleted
ij> insert into t values (1, 'PlanetSun');
1 row inserted/updated/deleted
ij> select \* from t;
ID         |ADDR                
--------------------------------
1          |PlanetSun           
1 row selected
ij> exit;


Any database that may have been created by desktop Java application can be read/modified on JavaME platform and the same database can be used by the desktop application again. This can be accomplished so easily only with Java-JavaDB combination!

Comments:

[Trackback] John Embretsen of Sun's Java DB team has just posted a thorough wiki page on using Derby on Java ME platforms. He also shows how to test Derby with IBM's J9 and Sun's phoneME implementations. The tips and tricks section...

Posted by Masood Mortazavi's Blog on November 30, 2007 at 03:11 PM IST #

Can you run Derby on any real-world mobile VM?

I mean, it's nice that you got a shrunken DB in a CDC VM on Linux to run (where you could theoretically run Oracle), but who cares if you can't get it to work in any real-world device?

Also, if Derby's performance is what I remember from CloudScape days, how fast is it going to be on a PDA? Slow? Unbearably slow? Abysmally slow?

Posted by Johann on December 09, 2007 at 07:25 PM IST #

You can use OpenBaseMovil, which has an on-device database with a much smaller footprint, runs on real JavaME CLDC (not CDC) devices, is really fast and also Open Source. It uses the MIDP RMS system.
OpenBaseMovil has more than just a relational database engine for Java Micro Edition, but that part of the framework is probably that gets more attention.

Posted by Narciso Cerezo on May 23, 2008 at 02:45 PM IST #

Has anyone tried NisCom's CrEme VM with JavaDB on a mobile device?

Posted by Philip Barnett on February 13, 2009 at 10:42 PM IST #

We are a startup company developing J2ME bases SQL database engine for all phones supporting CLDC 1.0 . MIDP 1.0 and CLDC 1.1 / MIDP 2.0. It has all standard SQL features and include advanced features like triggers. If any one is interested in obtaining a evaluation copy then please contact sanjiv.guha@zoduna.com or bruce.howard@zoduna.com

Posted by Sanjiv Guha on March 31, 2009 at 08:08 PM IST #

Hi I am planning to build a address book kind of app for MIDP mobiles. I need to have a local database file running on the mobile for my application. DO you have any sample code for using eclipse or netbeans and building such an application? If I run a db file in my mobile how may rows of records(I want to target 5000) can I handle. please help me in this direction.

Posted by Anandarajeshwaran.J on November 02, 2009 at 06:33 AM IST #

Hi, I am a experienced J2ee developer but right now i am trying my hands in J2me , can somebody guide me in developing how i should go about developing nice GUI for the cdc application.
I also need the link to various url for my setup..
My requirement is to work in Eclipse IDE and using Creme as JVM for Windows Mobile 6.
My desktop O/S is WINXP SP3.What should i need to know before i develop GUI for the CDC..What all software are needed beside the eclipse IDE and Creme and how do i integreate to make my enviornment.

Posted by Jayant on February 02, 2011 at 03:11 AM IST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

user13377336

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Bookmarks
Blogroll

No bookmarks in folder