Win a copy of Rust Web Development this week in the Other Languages forum!

Mike Bailey

+ Follow
since Mar 10, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mike Bailey

For any of you that bought the assignment before the acquisition of Sun by Oracle (like I did), here's what happened.

After explaining my situation, I got this:
"We would suggest that you complete the assignment and essay and mail us within 2-3 weeks. This process is undergoing a change and it will not be possible for you to upload the assignment after the 12 month period." followed by the boilerplate response that is included earlier in this thread.

After explaining there was no 12 month period for me, errr that 12 months had passed since I downloaded the assignment (it is almost 2 1/2 years since I bought the assignment) in a few emails back and forth (the CSRs don't seem to be overly competent) I got this response:
"We would request you to mail us the assignment as soon as possible, since the assignment process is undergoing a major change after the Oracle SUN merge. Please submit the assignment and the essay by 15th June, we cannot extend your deadline beyond that. "

Considering I got this mail on May 27th and had only done initial requirements and design work, I was a little worried. But I did pass and actually got my results really fast. I took the essay on June 14 mailed the jar in on june 15th, got an email that the assignment was sent to a third party for grading on June 17th, and got an email on june 24th that I had been manually certified on june 20th. I asked for my score, but the reply said that passing grades don't get a score. That stinks.
Your problem doesn't have anything to do with the format of your code.

You're reading the file just fine... but what actual bytes are you reading from the file when you call readRecord on a newly created repository? Look at your instructions again, especially the database schema section.

I would say your assumption about the interface method readRecord and what it should return are correct, however this doesn't have anything to do with what you're reading in your code.
I have URLyBird (v1.2.3), but I think this question may apply to all of the assignments. Did anyone implement an unbook on the client? Why or why not?
In your main you create a new Repository and then immediately call readRecord which reads the first RECORD_LENGTH bytes of the db file. Read your instructions again carefully, what are you really reading in?
Go here:
and buy it.

After you buy it there will be instructions for downloading it.
It really depends on the db schema given in your instructions. The instructions I have (URLyBird) don't have a primary key in the schema. For example there can be multiple records with the following values:
[*]Hotel Foo
So the DuplicateKeyException would never be thrown since there is no possible way to have a duplicate.

So, the static database variable is initialized each time a client connects and each client will get a different instance of DvdFileAccess.

I'm not seeing how each client gets a different instance of DvdFileAccess when it is declared static in DvdDatabase.

The above code prints out "Using same database". I still think the scenario I pointed out in my original post is possible (even likely under heavy code).

The if condition in second code block above is useless. And all the synchronized(database) code in DvdFileAccess is useless too, as by design, each client runs in its own thread and gets a different instance of DvdFileAccess.

I don't think each client gets a different instance of DvdFileAccess, the only access clients have to DvdFileAccess is through DvdDatabase, and since DvdFileAccess is static, all clients will share the same instance of DvdFileAccess.

And, this will effectively limit the number of concurrent users to the maximum number of file handles allowed to be opened by the OS.

That sounds right, but how does address the issue of the database static member potentially being accessed in an unsafe manner?
In the book SCJD Exam with J2SE 5 by Andrew Monkouse the DvdDatabse class (p. 135) has a static member database which is initialized in the constructor:

private static DvdFileAccess database = null;

public DvdDatabase(String dbPath)
throws FileNotFoundException, IOException {
database = new DvdFileAccess(dbPath);

other methods in the class use the database member as well:

public Collection<DVD> findDVD(String query)
throws IOException, PatternSyntaxException {
return database.find(query);

Looking at both the RMI and socket implementations different threads will create a DvdDatabase and use it. Isn't it possible that as one thread is executing:
database = new DvdFileAccess(dbPath);
another thread may slice in and call:
which will be excuting on a partially initialized object?