Serialization vs Embedded Database for simple standalone application
Say, I have a pretty simp开发者_开发技巧le 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?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?User settings are typically stored as
- properties, using the properties file format
- properties using the XML format
- preferences, using the Preferences API. This has the advantage of storing and reading user and system preferences for you, without having to think about where to store them, etc. See http://download.oracle.com/javase/1.4.2/docs/guide/lang/preferences.html
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.
精彩评论