This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes Database vs file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Database vs file" Watch "Database vs file" New topic
Author

Database vs file

Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
Hi guys
I need to save a counter that can be updated (quite frequently) from many different servlets, i cannot let the data it holds get lost in case tomcat is shut down, so the only two options i see for that are saving the counter in a database (MySQL) or in a text file.

My question is as far as you know, what is faster for opening and writing into, the database or the text file?

Thanks, Joseph


We must know, we will know. -- David Hilbert
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30400
    
150

Joseph,
A text file is likely to be faster. However, databases handle contention better. This may eat away at any time savings from the text file.

You could try both to see which works better for you.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
 
subject: Database vs file