Zonglin Li

+ Follow
since Aug 29, 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 Zonglin Li

Thanks guys!

Just want to make sure Herman passed this not because of luck, as this is a matter of SUN’s “muuuuuuuuust”.
Sorry found this old post, but it is really very important to me. And I think this is also a very common question.

Could any one passed SCJD to confirm with Herman please!

Many many thanks
There are two ways to create a new record. The simply one is to add the new record (with the new record number) at the bottom of the database. The second one is to reuse the deleted record number. Check your SUN requirement, if it is not a must to reuse the deleted record, then the first solution is straightaway.
Hi everyone:
I think there is a mistake in Andrew's DVD example. Inside the book, it uses 'CleanExit.java' to handle the server shut down. When the user shut down the server, 'CleanExit' will called by the JVM and do some clean up.

* This method will be executed by the JVM when the application is shutdown.
* It ensures that the database is in a clean state for shutdown (that is,
* there are no outstanding writes occuring).
public void run() {
log.info("Ensuring a clean shutdown");
try {
DvdDatabase database = new DvdDatabase(dbLocation);
} catch (IOException e) {
log.log(Level.SEVERE, "Failed to lock database before exiting", e);

I assume this is wrong. Because it creates a new database and locks the new database. The real database which has been used by the clients has not been locked for clean up.

Could anyone address please!

Thank you very much!
Hi Jeffry and Tom:
Thank you very much for your reply.

I think the method which you mentioned is a correct way. But I would like to follow Andrew Monkhouse�s DVD example to create a string with all the field�s values together (including the flag field) and write it together. So I need create a flag field string (two bytes with 0x8000). Do you have any idea how could I possibly do this please?

Hi Pete:
I am working on the Bodgitt and Scarper too.

Your Schema description section is wrong. At the starting point (the schema), the first 2 bytes will tell you how many bytes you will expect for the field name (the length of the field�s name not the field�s length). You extract the field name and then the following 2 bytes will give you the length of this field. You repeat this for 6 times.

Schema description section:
0010 2 bytes � length in bytes of filed name (if the result is n)
0012 n bytes (number of bytes should be different for each field)
� filed name
0012+n 32 bytes (different field has different length, which has already given to you on the requirement. The first field is 32 for name field.)� name length
Dear all:
According to my assignment, I have got two byte flag field and I should set 0x8000 to imply deleted record. Could any one give me an idea how I could create a two byte array which hold the 0x8000 please!

Thank you very much.
Hi Alecsandru:
Thank you very much for your reply. It is very clear.

If I want to get all the records, I could just set the criteria to: null null null null null. So I don�t need to create a method to get all the records. Do you think so?

I am doing the Bodgitt and Scarper. I am a little bit confusing about how to define the criteria in my �find� method.

My find is defined like this:
Field n in the database file is described by criteria[n]. A null value in criteria[n] matches any field value. A non-null value in criteria[n] matches any field value that begins with criteria[n]. (For example, "Fred" matches "Fred" or "Freddy".)

Could anyone explain this please!

Thank you very much!!
Hi Jethro
Thanks for your reply.
I am totally agreed with you.

Another reason for me raise this question is that I want to know why Andrew�s sample project doesn�t close the socket properly. I assume this is not difficult. Is it because I didn�t noticed the code which is in some where or it is not import for SCJD or it is just ignored by Andrew?

Thank you very much
Dear all:
Following Andrew�s book, when user try to exist from the server, it just exist the system (System.exit(0)) without closing the IO streams, client socket and server socket.

Although from the sample, there has the CleanExit class to protect the database, I still think it is still necessary close the server connections properly.

Do your guys think this is the right way to get better score for SCJD?

Any suggestions for this?

Thank you very much!
Hi Eric and Alexandre
Actually I have got the same question. In my opinion, �ReadWriteLock� only works for extract data from the database and write the data to the database.

For example, a user did a search, found the record number 1,2,3 and its GUI shows the values of these three records. At this moment these records are not locked (for write) anymore. If another user comes, he could get the lock and change the record (for example the record 2). So the record (record 2) showing for the second user and any future users is different comparing with the first user.

I am not sure is this the case or not.

Thanks in advance!