序列化与嵌入式数据库的比较,适用于简单的独立应用程序 [英] Serialization vs Embedded Database for simple standalone application

查看:93
本文介绍了序列化与嵌入式数据库的比较,适用于简单的独立应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说,我有一个非常简单的Java应用程序,它需要存储某些用户设置的方法. XML并不是一个很好的解决方案,因为我想以二进制形式存储它们.那么,在这种情况下,最好的解决方案是嵌入式数据库(例如Apache Derby)还是仅仅是简单的旧序列化?
我知道这是两个完全不同的事物,但是都允许保留某些应用程序状态.那你会选择什么,为什么?

Say, I have a pretty simple Java application that needs the way to store some user settings. XML is not a really good solution, since I want to store them in binary form. So, what would be the best solution in this case, embedded database (such as Apache Derby) or just plain old serialization?
I know that these are two completely different things, but both allow to persist some application state. So what would you chose, and why?

修改
至于存储简单的用户首选项,.properties或xml文件都可以,我也同意.但是,如果我想存储密码或一些特定于应用程序的数据怎么办?

Edit
As far as storing simple user preferences go, .properties or xml files are fine, I agree with you. But what if I want to store passwords, or some application-specific data?

推荐答案

由于Apache Derby是可嵌入的关系数据库,因此使用它来存储和处理关系数据是很有意义的.使用嵌入式数据库仅保留一些用户设置是有点过头了.

As Apache Derby is an embeddable relational database, it makes sense to use it for storing and manipulating relational data. Using an embedded db for persisting a few user settings only is a bit overkill.

如果是我,我将使用简单的键/值对序列化来保留用户设置.

If it were me, I would use a simple key/value pair serialization for persisting user settings.

这篇关于序列化与嵌入式数据库的比较,适用于简单的独立应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆