• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

about record index

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Barry Tsai
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,Javini

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

best regards
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic