开发者

Simple pojo persistence without database

开发者 https://www.devze.com 2023-03-20 00:21 出处:网络
I have a very simple web project, which need to just persistence some \"users\", each one just have a few fields(\"username\", \"password\").

I have a very simple web project, which need to just persistence some "users", each one just have a few fields("username", "password").

Now I persistent them into a database, but I think it's too heavy.

I wonder if there are some easy ways to persistent them without开发者_如何学编程 a database. It's great just need to save pojos directly.


UPDATE

To save them in a file directly(like serialization, properties file) is easy, but not easy with CRUD. That means, when I get a specified user, I have to load them, then check the username one by one. When I update or delete one, I need to load all and save all.

I hope something like db4o, but with a good licence(not GPL nor commercial). The performance is not important here.


You could use the built-in serialization for Java or have a look at some of the XML serializers, like simple.

SQLite might be a suitable alternative to a client/server type database, but use from Java is a little awkward, as some native libs are required.


Using Properties file is another solution, http://download.oracle.com/javase/tutorial/essential/environment/properties.html But note that you're storing passwords, you might need to encrypt them

0

精彩评论

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