aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes about record index 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 "about record index" Watch "about record index" New topic
Author

about record index

Barry Tsai
Greenhorn

Joined: Jul 16, 2003
Posts: 12
hi, guys
I got the other problems.
would you kindly tell me how to do??
1.In the db file don't have record number.
How could I update the record to use readRecord method in Data.java??
The following is readRecord method:
"public String [] readRecord(long recNo)"

2.when user run the GUI in local model.
Should I let user to choice the db file??

Best Regards,
Barry
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
hi Barry:
1) In my project, I used the record index number as the record number. I loop through the database file, and every time I read a record, I increas the record number by 1.

2) My instruction stats that I must allow the user to choose a local databas file, so that in client GUI I allow the user to to choos DB file.
You have to go back to your instructions.


SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Along huang
Ranch Hand

Joined: Feb 09, 2004
Posts: 72
I encounter the same problems, that push me into rattrap! my appliction is at design phase and I can nearly not go on.

to Hanna:
In my project, I used the record index number as the record number. I loop through the database file, and every time I read a record, I increas the record number by 1.

as your way, the efficiency of the system will be worrying. I don't think it is a good way.

I ever thought to create a new db file to store recNo, but I don't know if Sun permit me to do so.

best regards


SCJP1.4 SCJD 2<br />SCEA(In progressing)
Barry Tsai
Greenhorn

Joined: Jul 16, 2003
Posts: 12
I agree with Along.
In the local model maybe that's ok.
But if in the network model when two client access the same server.
That will be counter the mistake.



Barry
Javini Javono
Ranch Hand

Joined: Dec 03, 2003
Posts: 286
Hi,


as your way, the efficiency of the system will be worrying. I don't think it is a good way.


More than likely, when he says "increase the record number," this is a form of
random access, probably used in the one case where the user requests implicitly,
perhaps through a search, that all the records by displayed.

I think that it is necessary to define "record numbers" that exist within the file,
which is superimposed upon the structure of the file. Just like an array list
has "indeces" or "record numbers" so that it can be accessed randomly.

Thanks,
Javini Javono
Along huang
Ranch Hand

Joined: Feb 09, 2004
Posts: 72
hi,Javini
I think that it is necessary to define "record numbers" that exist within the file

My opinion is consistent with yours, but Sun don't permit to alter the struction of the original db file, as the system is required to be compatible with the existing system.

Now the problem is,with keeping the original db file, whether I can create a new db file?

best regards
Javini Javono
Ranch Hand

Joined: Dec 03, 2003
Posts: 286
Hi,

I'd start out using JEdit and a plug-in called HexEdit; www.jedit.org.

Look at the database file sun supplied (or even better, of course,
copy it to another filename so as not to damage that very
important file).

Assume that the header says that every record is 10 bytes long.
Then bytes 0 through 9 is record 0.
Bytes 10 through 19 is record 1, and so forth.

And, you'd also have to take into account the offset or space
the header itself take up at the beginning of the file.

The first thing I did when I received this assignment was to
dump out the file, compare the values in it with the assignment
instructions, look for inconsistencies, and then write a small
program to read in the header information and then read in
all the data in the file.

Thanks,
Javini Javono
Along huang
Ranch Hand

Joined: Feb 09, 2004
Posts: 72
hi,Javini

Could you tell me how you solve the problem on "recNo"?

best regards
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
hi all:
all of your choices are very interesting and make more sense than mine. However, In my desgin, record numbers doesn't mean much. First, I don't delete any records from the database, I mark them as deleted only, and I don't use deleted entries- of course I stated the reason in my choice documents.
In the presentaion side, when a user attempts to update or delete a record, the record information is displayed to the user first to conform that what he meant to do, then I delete or update. I handle the change of record information in the locking mechanism.
Because I don't delete any records, record number remain unique, an I am ok with that choice.
Along huang
Ranch Hand

Joined: Feb 09, 2004
Posts: 72
I have found the answer about recNo!

First of all,In my db file,we must make sure two data as follow:

1). in a record,the length of all pure fields aggregate 159 bytes, record flag is 2 bytes, therefore, a record totally occupy 161 bytes.
2).the database file-header ocuppy 74 bytes, i.e.,it occupy the space before the record zero.

hence,reading data from db file must base on the file-header, and must read 161 bytes for a record each time. then the offset of the current pointer in db file is divided by 161, the quotient value is the recNo.

if any one have better idea, please tell me.

best regards
 
jQuery in Action, 2nd edition
 
subject: about record index