i'm writing a program that 1. gets information in form of question; answer; date (daily from a website) 2. stores this in a manner that is accessible by choosing date
(I am able to implement first part of this )but how can i save this info, since it seems that HashMap, HashTable etc only stores key/value pairs.
thanks for your response. being new to programming in general, can some explain to me why use databases, sql etc, if you can store information in collections?
It depends on how long you need to keep the information, and how many people need access to the same information, and If that information needs to be shared outside of the Java App, and even accross multiple JVMs, RMI not withstanding.
So in a Collection the information is only in memory for so long as the Collection is referenced and in scope. In a database it is stored for longer than you apps lifecyle, or most anything.
wouldn't it be possible to save to Collection's state to a file on exit from the application, and have the file continuosly updated. (...I'm reaching here guys...trying to avoid learning about databases right now!)
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
posted
0
Originally posted by kwame Iwegbue: wouldn't it be possible to save to Collection's state to a file on exit from the application, and have the file continuosly updated. (...I'm reaching here guys...trying to avoid learning about databases right now!)
Yes it IS possible. And for small programs it is even feasible. However, as the amount of data you need to store grows larger, this solution does not scale well. What I mean is that a so called "flat file" works fine for perhaps a few hundred elements from the Collection. However, if you need to store millions of elements and do various searches on them, performance is significantly degraded. Databases are much more efficient at searching through large amounts of data.