wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S Booking and locking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S Booking and locking" Watch "B&S Booking and locking" New topic
Author

B&S Booking and locking

Denis Zjukow
Ranch Hand

Joined: Mar 15, 2006
Posts: 39
Hi. My spec says that I have to provide booking in the application. What actions have to be performed to book a record? Should I only lock it or not? Thanks!!!
Chulwoo Choi
Ranch Hand

Joined: Apr 11, 2005
Posts: 65
Hi,

Three actions to perform:
1. lock the record
2. update the record to set the owner field with the customer's ID (by calling the updateRecord method)
3. unlock the record

(By the way, my project is B&S too.)

Chulwoo
Denis Zjukow
Ranch Hand

Joined: Mar 15, 2006
Posts: 39
Chulwoo, thanks for the reply. I got another question then . Here it is: what is the 'magic cookie value'? My data file the header starts with it:
Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
4 byte numeric, total overall length in bytes of each record
2 byte numeric, number of fields in each record

...

Does anyone have any idea?

And my last question for today: how should I handle the ordinary cookie values? The ones that are parts of records. In B&S they go in column 'owner'. My spec says the following: 'The id value (an 8 digit number) of the customer who has booked this. Note that for this application, you should assume that customers and CSRs know their customer ids. The system you are writing does not interact with these numbers, rather it simply records them. If this field is all blanks, the record is available for sale.'

Could anybody explain to me what is the meaning of 'does not interact with these numbers, rather it simply records them'! How can I write them if I don't interact with them?! Should I ask a used to eneter his/her id when the app. starts? Or what?

Thanks for your help!!!
[ November 09, 2006: Message edited by: Denis Zjukow ]
Mike Ngo
Ranch Hand

Joined: Oct 16, 2006
Posts: 89
The magic cookie identifies a file as a valid database file. For example, if your database file starts with the cookie '0x000A000B', you should check when you open a file to make sure it has this cookie to be sure that the file is valid.

I am not sure if everyone has the same magic cookie. I just open my file and print out the hex value and code it in my application so that it won't open any file without that value.

As for the customer Id, normally when you book a reservation, you will need all those customer info such as name, address,... For this assignment, you only need to input the customer Id.
Btw, I am working on URLyBird but it has the same requirement for the customer Id.
Denis Zjukow
Ranch Hand

Joined: Mar 15, 2006
Posts: 39
Originally posted by Mike Ng:
The magic cookie identifies a file as a valid database file. For example, if your database file starts with the cookie '0x000A000B', you should check when you open a file to make sure it has this cookie to be sure that the file is valid.

I am not sure if everyone has the same magic cookie. I just open my file and print out the hex value and code it in my application so that it won't open any file without that value.

As for the customer Id, normally when you book a reservation, you will need all those customer info such as name, address,... For this assignment, you only need to input the customer Id.
Btw, I am working on URLyBird but it has the same requirement for the customer Id.


Thanks Mike,

Hm. Having hardcoded the magic cookie value you disallow a user to change the data file, don't you? I think it would be nice to add a feature of pluging different files. What do you think?

Or maybe we should think of this value as of something like a certification: every data file of a concrete type should have this and only this magic cookie value?

I've just found another problem with locking. My data base interface provided by Sun defines the following method signature:

public long lock(int recNo) throws RecordNotFoundException;

Keeping in mind that a cookie is a user id I don't see how we can find out what value to return. Inside the method I don't have any info of the user. So what do I have to return? A random value? Current time? But having done one of these I break the owner's rule: 'The id value (an 8 digit number) of the customer who has booked this. Note that for this application, you should assume that customers and CSRs know their customer ids. The system you are writing does not interact with these numbers, rather it simply records them. If this field is all blanks, the record is available for sale.' The column's value must be a user id or empty? How are you, guys, solving it? Thanks!
Mike Ngo
Ranch Hand

Joined: Oct 16, 2006
Posts: 89
I think Sun makes you confuse.

magic cookie -> identify a valid database file
lock cookie -> this is an Id your database server generates every time it locks a record. It is a running counter. The server gives to the client who locks the record so that only that client can work with the record.
Denis Zjukow
Ranch Hand

Joined: Mar 15, 2006
Posts: 39
Originally posted by Mike Ng:
I think Sun makes you confuse.

magic cookie -> identify a valid database file
lock cookie -> this is an Id your database server generates every time it locks a record. It is a running counter. The server gives to the client who locks the record so that only that client can work with the record.


Lock cookie is kept in the data file. There is 'owner' column for that reason. Right?

On the other hand, describing 'owner' column, the spec says it has to be a user id: 'The id value (an 8 digit number) of the customer who has booked this'! (I talking about B&S).

From my point it is not a generated number.

Please tell me where I'm wrong.
Mike Ngo
Ranch Hand

Joined: Oct 16, 2006
Posts: 89
"owner" column stores the customer Id. If there is no customer Id in the owner column, that record is available for sale.

The lock cookie is generated by your database server whenever it locks a record.
Denis Zjukow
Ranch Hand

Joined: Mar 15, 2006
Posts: 39
So I will need to have some collection to store the cookies on the server, correct? I just thought of booking and locking as of the same things Thanks for clarifying me that they are not!
Mike Ngo
Ranch Hand

Joined: Oct 16, 2006
Posts: 89
Yes. You need a Hashtable/HashMap to store lock cookies {recNo, lockCookie}.
 
wood burning stoves
 
subject: B&S Booking and locking