File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes A database or not ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "A database or not ?" Watch "A database or not ?" New topic

A database or not ?

Martin Swift

Joined: Feb 13, 2003
Posts: 13
I have a design question. I am about to write a program that collects information from an end user and then store this information somewhere.
The most effective, and commonly used solution to this would be to store the gathered information in a database. But how should I do this in a platform independent way and so the solution is transparent to the end-user?
Is it a good solution to ship the application with a small footprint database written in Java, Is there any open source solution I could use?
Maybe I don�t need a database at all, can I use XML or properties files instead?
I would greatly appreciate some suggestions or thoughts on this subject
Regards Martin
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
TThe first question that comes to mind is: What do you have to do with this information later? The answer to that will suggest which direction to go.
For a small footprint all java, open source database I don't think you can go wrong with Hypersonic (hsql) see the Sourceforge page here.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
using properties files or XML might lead to potential privacy and security problems.
With databases there's generally some security where only people and applications with the correct username and password can get at the data.
With XML and properties files you have all your precious information for everyone to read who can get at the directory.

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Take a look at Prevailer ( Maybe this are the solution you are looking for?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Let the requirements lead you ... do you need the features of a database like ad-hoc queries, referential integrity, ACID transactions, ability to use a 3rd party reporting tool, security, etc? Or would the ability to view or hand-edit flat files be of value? Would distributing, installing and managing a database be too complex?
Since you're not sure and the answers may change over time as you think about it or get the first batch of users involved or start to get huge volumes, you might put some effort into isolating the decision from the rest of your application. Build your own API layer with get, put, delete operations and hide the decision inside the smallest number of classes you can manage. In other words, try to make it not matter.
Zat help?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ben Dover
Ranch Hand

Joined: Jan 30, 2004
Posts: 91
If your business case suggests an embedded persistence mechanism is the way to go, and if youre comfortable with deep xml, maybe a native XML database might be a solution. Apache Xinidice for example. Challenges such as representing objects and their references as XML and vice versa will be inevitable. Domify anyone?
I agree. Here's the link:
subject: A database or not ?
It's not a secret anymore!