Developing database applications for the Bug Platform can be challenging, mostly because phoneME
doesn't support JDBC. A viable solution to this problem might be installing a different JVM, one which supports JDBC,
like cacao or openJDK.
However, like almost any solution in the computer world, nothing comes for free; by switching
phoneME for cacao or openJDK you'll sacrifice speed in order to gain more functionalities (see kschultz JVM Comparison post).
Recently, I wrote an app that uses openJDK+cacao and connects to a MySQL database. If you want to try it out , here are the steps you need to take. They are not hard but rather tedious.
Setup Dragonfly
First, we need to set up Dragonfly
- Open Dragonfly.
- Create a new Bug Application. File->New->Other->Bug Application
- Right click on the project and select Properties->Java Build Path->Libraries
- Remove PhoneME Personal Library.
- Then, press Add Library..., select JRE System Library and click Next, choose a JRE, press Finish, and then press OK.
- Create a folder call lib within the project directory [WORKSPACE_PATH]/[YOUR_APP_NAME]/lib
- Download Connector/J 5.1 , extract the mysql-connector-java-5.1.7-bin.jar file and place it in the recently created /lib folder
- Finally, add the following line to your Manifest file
Bundle-ClassPath: .,lib/mysql-connector-java-5.1.7-bin.jar
Now, you can use JDBC to write an application that connects to a MySQL database.
Install opendJDK+Cacao
By default, the bug comes with phoneME. Good thing that the team here at BugLabs has done some work to port openJDK+Cacao to the Bug. So, you just need to install the new JVM and configure concierge to use it.
- First, download these files: cacao-openjdk_0.99.4-r0_armv6.ipk, openjdk-6-cacao-jre_6b16-r2_armv6.ipk
- Transfer the files to your BUG:
- Log into your bug
- Then, install the packages
- The next step is to tell concierge to use the new JVM. Open the start.sh file
- Restart concierge,
$ scp *.ipk root@10.10.10.10:/home/root
$ ssh root@10.10.10.10
root@10.10.10.10's password:
...
$ ipkg install cacao-openjdk_0.99.4-r0_armv6.ipk
...
$ ipkg install openjdk-6-cacao-jre_6b16-r2_armv6.ipk
...
$ vi /usr/share/java/start.sh
and chage the class path
# CVM_DIR=/usr/lib/jvm/phoneme-advanced-personal-debug
# CVM_PATH=/usr/bin/java-cdc
# CVM_PARAMS=
CVM_DIR= /usr/lib/jvm/java-6-cacao
CVM_PATH=/usr/bin/java
CVM_PARAMS=
$ /etc/inti.d/concierge restart
...
and you should have concierge running on top openJDK+cacao.
Install MySQL
Next, we are going to install MySQL server and client into your bug:
- First, download the packages (you can always build them yourself): libmysqlclient14_4.1.18-r3_armv6.ipk, mysql-server_4.1.18-r3_armv6.ipk, mysql-client_4.1.18-r3_armv6.ipk
- Transfer the packages to your BUG from terminal, shell or any other SCP program:
- Log into your bug and install the packages:
- We need to make one more change before start the server. MySQL needs write permission of the /var/run folder
- To start the server just type
- If you want MySQL to start at boot time, just make a symlink from your run-level directory
$ scp *.ipk root@10.10.10.10:/home/root
$ ssh root@10.10.10.10
root@10.10.10.10's password:
...
$ ipkg install libmysqlclient14_4.1.18-r3_armv6.ipk
...
$ ipkg install mysql-server_4.1.18-r3_armv6.ipk
...
$ ipkg install mysql-client_4.1.18-r3_armv6.ipk
...
$ chmod 757 /var/run
unfortunately this is just a temporally solution, because the /var/run folder is volatile (non persistent)
,so, every time you reboot your bug you will have to change the permission of the folder.
A way around this problem is to change the default permission of the /var/run folder when is created.
We can do this by
# Open this file
$ vi /etc/default/volatiles/00_core
# and change the following line from
d root root 0755 /var/run
# to
d root root 0757 /var/run
Now every time the bug is started the /var/run folder has write permission.
$ /etc/init.d/mysqld start
# S50 tells the system to start mysql when it boots up
$ ln -s /etc/init.d/mysqld /etc/rc.d/rc5.d/S50mysqld
# K50 tells the system to stop mysql when it shuts down.
$ ln -s /etc/init.d/mysqld /etc/rc.d/rc5.d/K50mysqld
That's it, you are ready to create and run database apps on the Bug. If you have any question or problem, just jump into the IRC channel or email me.
Loading recent content...





Post Comments
Add Your Comment!
Right now there is no app at BugNet, but I think I'll post one soon.
This is great Irvin! How do you run SQL queries from BUG app?? Is there any sample apps on BUGnet?
» Comments RSS