Stella Peristeraki
Stella Peristeraki

Reputation: 289

Avoid using a DB for storing small set of data on a Java EE App

I have a small JSF app and would like to keep some state on the server, without using a DB. It will just be a small string for every user so I don't see the point in deploying an RDMS for that.

Upvotes: 0

Views: 197

Answers (4)

Maksim
Maksim

Reputation: 91

I think it's also make sense to utilize some caching solution for this case. jBoss tree cache for example, you can define some specific region to store small entries.

Upvotes: 0

sfussenegger
sfussenegger

Reputation: 36096

You could use Derby which makes the deployment of an RDBMS less of a "point".

Alternatively, you could use a diskPersistent Ehcache - you use it similarly to a Map but data persists during restarts. You'll have to make sure that your JVM is cleanly closed or element in memory might get lost (you can make sure that elements are written immediately to a file by setting maxElementsInMemory to 0 though)

Upvotes: 1

Brian Agnew
Brian Agnew

Reputation: 272257

Check out the Java Preferences API which can store info per-system, or per-user (not so relevant for this scenario)

Applications require preference and configuration data to adapt to the needs of different users and environments. The java.util.prefs package provides a way for applications to store and retrieve user and system preference and configuration data. The data is stored persistently in an implementation-dependent backing store. There are two separate trees of preference nodes, one for user preferences and one for system preferences.

Upvotes: 1

OMG Ponies
OMG Ponies

Reputation: 332581

Use a properties file: http://www.exampledepot.com/egs/java.util/Props.html

Upvotes: 1

Related Questions