Rob Zidsen

Greenhorn
+ Follow
since Jul 07, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rob Zidsen

Well, no response so maybe I'll try to edit this to be clearer:
How do I specify a fixed number of rows I want displayed in my table? For example, say I want my table to be 10 rows deep at all times. If there are less than 10 total records, the table will still be 10 rows deep in height. If there are more than 10 rows, than JScrollPane will take care of the scrolling, but the height will still be only 10 rows deep.
[ September 03, 2003: Message edited by: Rob Zidsen ]
thanks for your help guys. that's the problem I guess. I didn't reset the buffer position to 0.
In my testing, I notice a little quirk, and I don't really know how to explain it. This is the problem:
In my read() method, I check for the record's validity and throw a RecordNotFoundException if the valid flag is not 00:

This seemed to work fine in my testing.
THEN I added an catch-all catch statement to read():

For some reason now, this catch statement catches the RecordNotFoundException I'm trying to throw to the calling class!! The calling class no longer catches RecordNotFoundException because of this, obviously. Of course I took out this catch statement and all is well again, but I still don't understand why it's doing this. Can someone enlighten me?
Tony, why should I care where the FileChannel is pointing? I'm not reading/writing relative to it's current position. I'm using an absolute file position to write the data.
Hello Max,
I'm just having trouble with the read/write operations sometimes. It seems to work in some places, but in other places it doesn't work. I've tried moving where I created the byte buffer, etc. to geti t to produce the results I want, and sometimes that works, too. Although to be honest that makes me even more concerned.
Here's a snippet of the code that works in most places but isn't working in create():

here's my Random Access File substitution:
A note to those unfamiliar with NIO and thinking of using it: Stay away from these things! They've caused me so much headache over the last couple of days. Stick with RandomAccessFiles. I swear, I use the exact same code in some places and sometimes it works, sometimes it doesn't. It's unreliable. It's maddening. I'd be so much further along now if I hadn't tried to incorporate these things.
I've never had these problems using RandomAccessFiles. Sure, it's a bit slower, but who cares. Stick with what works. Save yourselves the headaches.
To prevent dirty reads and such, would you guys recommend locking the whole database when performing find()? This would prevent one thread from changing a record in the middle of another thread searching through the whole database to find matching records. On the other hand, this may cause clients to appear to hang if there are too many calls to find() and the database is large.
I'm having this really strange problem with file channel now, and I hope someone can help me.
basically I have a method I call that checks the validity of a record. I use this method in my read and modify methods. I was using RandomAccessFile, and everything was fine. Then I just changed to FileChannel because everyone's saying how much more efficient it is, and it's messing up my db when i perform updates, deletes, etc.
here's the part using random access file:

and here's the part using file channel:

I really don't understand why such a small changed messes everything up.
In all my modifying methods, I use FileChannel as well. I'm using the same FileChannel instance in all my calls, since I've made it a member of Data. Is this somehow causing the problem?
what would you suggest? store it in memory? what if the file was very large?
Hi Andrew,
If there is only one RandomAccessFile that all threads are sharing, couldn't this lead to synchronization problems? For example:
Thread one calls seek(position) just before it does a write. After the seek but before the write, another thread interrupts and grabs priority. This second thread then calls seek(anotherPosition) and does a write operation. When the original thread gets priority back, can it potentially write to the wrong location?
This is the reason I instantiated local RandomAccessFiles everywhere. to prevent something like that from happening. Is such a scenario plausible?
Right now I have a File as a member of my Data class and in all my methods I create a new instance of RandomAccessFile on the File. It's a bit more convoluted to code because I have to open and close RandomAccessFile all the time. Should I change it?
Hi,
The instructions say "Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, <bold>consuming no CPU cycles</bold> until the desired resource becomes available."
If I use a hashmap as my lockmanager, and synchronize on it, then a call to notifyAll() would cause all sleeping threads to wake up even if if they're waiting on a different record to be unlocked. However, searching thru the archives this seems to be what everyone else does anyways, so should I be worried about this or not?
I don't know why, but I can't get my version of the manifest file into the jar file I create. I know I'm putting in the right command, but when I check the manifest file in the JAR archive, it's just the default one supplied by sun.
Is there a way to extract that one and insert my one manifest file?
The instructions state that the GUI "must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user."
So in my mind, this means that we don't have to let the user search by specialty. Is this right? Only name and location are searchable?
This seems to contradict the whole purpose of the application, which is to "generate a list of contractors that match a customer's criteria." The criteria usually involves the actual service being requested, right??
Sorry for the dumb question.
I'm just looking at the schema and there is no field for the record number. but the DB interface specifies retrieval by record number. what am I missing? Is there someone who can explain the data file format better than the instructions?