Two Laptop Bag*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX:what is the magic cookie and what ...?(contrator) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX:what is the magic cookie and what ...?(contrator)" Watch "NX:what is the magic cookie and what ...?(contrator)" New topic
Author

NX:what is the magic cookie and what ...?(contrator)

song bo
Greenhorn

Joined: Aug 03, 2003
Posts: 16
hi,everybody.
the first question:
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

what is the meaning of the magin cookie value?what functions for it?"Identifies this as a data file",why?
the second question:
Locking
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above. You may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server. Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available.

I have seen many discussions here about the record or database locking and unlocking.should I lock the whole database?if so.why?when should I do this action?I only want to lock the record by recno.thus it's avaiable to handle mutiple connections.
thanks.
ulvi ugur
Ranch Hand

Joined: Aug 05, 2003
Posts: 46
Originally posted by song bo:
hi,everybody.
the first question:
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

what is the meaning of the magin cookie value?what functions for it?"Identifies this as a data file",why?
the second question:
Locking
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above. You may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server. Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available.

I have seen many discussions here about the record or database locking and unlocking.should I lock the whole database?if so.why?when should I do this action?I only want to lock the record by recno.thus it's avaiable to handle mutiple connections.
thanks.

Hi song,
The magic cookie number is there for you to verify that this is the file you are looking for. When the user assigns a wrong file, you can say "Chosen file is not valid !".
About locking, well I guess there is no need to lock the database, only locking records must be enough with the networked run. With standalone run, I'm not sure if there could/should be a file locking so that only one user can get connected to the db file. May be sb. else would say stg. about that :roll:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX:what is the magic cookie and what ...?(contrator)
 
Similar Threads
NX: Cookie value
[Bodgit Scrapper] what's the meaning of magic cookie value?
How to read MAGIC for db-2x2.db
Relationship among Data class, RAF instance(s), and clients
NX:About MAGIC flag in the Data file