| Author |
NX:Another way of accessing database
|
HaoZhe Xu
Ranch Hand
Joined: Nov 03, 2003
Posts: 222
|
|
|
Many people are using RandomAccessFile to access the database, can I just use a stream to read all the data in the database and store it in a structure, then it will be easy to search/book/modify it, because there're only 7 records in the database?
|
[url]Olnex.net[/url]
[SCJP 1.2, SCJD, SCWCD]
|
 |
Suresh Bansal
Ranch Hand
Joined: Jul 23, 2001
Posts: 91
|
|
|
In that case, how do you plan to handle updates to the data by multiple clients.
|
Journey is as important as the Destination.<br /> <br />PMP, SCJP, SCJD, SCEA (Part 1), SCMAD, SCDJWS
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10816
|
|
Hi HaoZhe, Several people here are caching the records in a similar manner. This will give you a system that will have better performance than one which accesses the hard drive for every operation. I don't think Suresh's concern is a big issue: no matter which way you write your Data class you should be ensuring that only one instance of a class can access / modify the data at any given time. So if you were doing physical disk operations you might choose to have only one instance of the Data class (or a helper class for the Data class) which does all the disk operations - all clients must use that one instance of the Data class. Similarly if you have cached the records, you would presumably have only one class which controls / accesses the cache, and all clients access that one instance of the cache controller class. (As an aside, I think Max at one time suggested that the lack of I/O exceptions in the signatures of the methods of the Data class could be argued as another reason for a cache ). But you do have to make a decision about how you handle bookings. It is probably best to write each booking to disk as soon as it comes in. If you do not, you run the risk of loosing all bookings if the server crashes. Regards, Andrew
|
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
|
 |
Suresh Bansal
Ranch Hand
Joined: Jul 23, 2001
Posts: 91
|
|
I agree, its caching on server side, i confused it with caching on client side
|
 |
 |
|
|
subject: NX:Another way of accessing database
|
|
|