File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 29247
    
139

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Database vs file
 
Similar Threads
scraping a SWF file in java
Javascript code is required
How to create a counter in my page?
Declaring a PrintWriter object
Access counter for servlets