aspose file tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX:Another way of accessing database Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "NX:Another way of accessing database" Watch "NX:Another way of accessing database" New topic
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
    
  25

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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: NX:Another way of accessing database
 
Similar Threads
Sharing data between web app's
Large Files
share data
Tech Word Game
Shopping Cart - Part 2