开发者

J2SE and Java DB

Greetings,

My Java experience is limited, but I have a fair enough understanding of it. With that in mind, I am attempting to write a mobile application with a self-contained database -- Java DB -- for the purpose of maintaining my fitness log.

Netbeans is my preferred IDE, and it is currently of the latest stable version and Java DB is installed -- indeed the database is ready and waiting -- but I simply cannot figure out how to attach a Java DB to a J2SE project.

Searching for tutorials and what not online lead me to Java Desktop Applications w/ a self-contained database, and when I attempt to port the import statements to a J2SE project, I receive nothing but import errors -- even with adding the Java DB jar files to the pr开发者_开发问答oject library.

Any assistance or point in the right direction would be greatly appreciated. Also, I am not deadset on the use of Java DB, and so if another portable database is preferable, then I am open to suggestions.

Thank you


J2SE is very different to J2ME. J2ME contains a cut down VM and does not have many of the features (e.g. generics, iterators, collections, reflection, finalization, thread groups, JNI ) that you would normally find in J2SE.

J2ME is not the platform to use for logging lots of information and trying to display it in informative graphs. A typical MIDlet can store around 2MB of information, although this varies between devices and is not a definitive number.

J2ME was designed for devices with little memory, so it has a small max heap size. This means that you would most likely run out of memory trying to display over a months worth of detailed fitness information.

There are a limited number of J2ME graphing APIs and because of the limitations of the platform, none of them can display graphs in a manner you'd expect in J2SE.

As another person mentioned J2ME uses a RecordStore to persist information. It can only store byte arrays which normally means you start writing your own very light serialisation framework for storing objects. Where every object you want to serialize implements a toByerArray() and fromByteArray(byte []) interface. However you can use other frameworks which will serialize objects for you.


http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javadb/


If you're thinking of writing your app to run on the MIDP platform, you'll be sorely disappointed because JavaDB won't work on MIDP. J2SE != MIDP by any stretch.


Don't know if this is still needed .... as an alternative to JavaDB you can use the Midlet Record store. Here are some readings

  • basics

http://developers.sun.com/mobility/midp/articles/databaserms/

http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/rms/RecordStore.html

http://developers.sun.com/mobility/midp/articles/persist/

  • applications

http://www.roseindia.net/j2me/record-store.shtml

http://www.roseindia.net/j2me/read-write-midlet.shtml

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜