This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JDBC and Relational Databases 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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Database vs file" Watch "Database vs file" New topic

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
author & internet detective

Joined: May 26, 2003
Posts: 32819

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Database vs file
It's not a secret anymore!