简体   繁体   English

J2SE和Java DB

[英]J2SE and Java DB

Greetings, 问候,

My Java experience is limited, but I have a fair enough understanding of it. 我的Java经验有限,但是我对此有足够的了解。 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. 考虑到这一点,我试图编写一个具有独立数据库Java Java的移动应用程序,以维护我的健康记录。

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. Netbeans是我首选的IDE,它是最新的稳定版本,并且已安装Java DB(确实已经准备好等待数据库),但是我根本无法弄清楚如何将Java DB附加到J2SE项目。

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 project library. 搜索教程和不在线的内容会使我进入带有自包含数据库的Java桌面应用程序,并且当我尝试将import语句移植到J2SE项目时,除了导入Java罐子之外,我什么都没收到,只有导入错误—文件到项目库。

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. 另外,我对Java DB的使用也没有犹豫,因此,如果最好使用另一个可移植的数据库,那么我愿意接受建议。

Thank you 谢谢

J2SE is very different to J2ME. J2SE与J2ME非常不同。 J2ME contains a cut down VM and does not have many of the features (eg generics, iterators, collections, reflection, finalization, thread groups, JNI ) that you would normally find in J2SE. J2ME包含缩减的VM,并且没有通常在J2SE中会发现的许多功能(例如,泛型,迭代器,集合,反射,终结处理,线程组,JNI)。

J2ME is not the platform to use for logging lots of information and trying to display it in informative graphs. J2ME并不是用于记录大量信息并尝试将其显示在信息图表中的平台。 A typical MIDlet can store around 2MB of information, although this varies between devices and is not a definitive number. 一个典型的MIDlet可以存储大约2MB的信息,尽管这在设备之间有所不同,并且不是确定的数字。

J2ME was designed for devices with little memory, so it has a small max heap size. J2ME专为内存很少的设备而设计,因此最大堆大小较小。 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. J2ME图形API数量有限,并且由于平台的限制,它们都不能够以您在J2SE中期望的方式显示图形。

As another person mentioned J2ME uses a RecordStore to persist information. 正如另一个人提到的那样,J2ME使用RecordStore来保存信息。 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. 您要序列化的每个对象都在其中实现toByerArray()和fromByteArray(byte [])接口。 However you can use other frameworks which will serialize objects for you. 但是,您可以使用其他框架来为您序列化对象。

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. 如果您打算编写可在MIDP平台上运行的应用程序,则会感到非常失望,因为JavaDB无法在MIDP上运行。 J2SE != MIDP by any stretch. J2SE!=任意扩展为MIDP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM