aspose file tools*
The moose likes Servlets and the fly likes Storing user infos: text files vs database approach Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Storing user infos: text files vs database approach" Watch "Storing user infos: text files vs database approach" New topic
Author

Storing user infos: text files vs database approach

Micky Pat
Greenhorn

Joined: May 03, 2006
Posts: 18
Guys,

a general question: what are the pros / cons of the two approaches described in the subject?

Say that I have a website with a servlet, and say that each user can store on my server some infos (for example, an agenda).
Now, everyone seem to suggest that using some form of database is the approach to follow.
What's the bad point about using some plain files, stored somewhere within the servlet?
- is a performance issue?
- is a "bad practice" problem?
- if there are a lot of users, the database will deal with the situation better...
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12805
    
    5
If your design of the information to be stored is still unsettled, go with XML formatted text files. The reason being that XML can evolve MUCH more easily than database tables.

BUT: If you design your user info access interface correctly you will be able to switch from the flexible XML format to the more scalable database format when you finally decide that the evolution of the user info contents is finished.

Bill
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

My big concern is what happens when you go Megalomart and have to cluster your servers. If you've got servers running on three different machines, how does your Servlet keep all those files in sync. At least a database is centralized, and the Transaction API can keep things atomic.

I may be small potatoes, but I'm always thinking big time! Think about scalability.
Micky Pat
Greenhorn

Joined: May 03, 2006
Posts: 18
William, Kameron,



thank you for your experiences...
In principle, anyway, is not a wrong approach using plain files... it can cause problems for big applications...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing user infos: text files vs database approach