• Post Reply Bookmark Topic Watch Topic
  • New Topic

random access files

 
komaravolu raju
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a student databse program in java files. I have some serious problems.
I am able to insert the data correctly into the file and can not retrive the specified data item only first colum needed,more over how to update a recoed and delete a paeticular student recoed 4rom a random access files.

I use only 4 fields for trail. student no, name, phone.

I wanna implement search on this. can nay one do some code help and/ or logic help.
 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, if I understand you right, you're trying to simulate a database table using a random access file. You'll first have to decide on the data structure. Will each field have a fixed length, or will there be delimiters? What advantages and disadvantages does each approach have? Howe will you find a particular record? The row itself could be a fixed length, or there could be some kind of index. How will you delete a record? You could mark it as deleted, or you could remove it physically.

Let us know some details of your implementation ... what is working, and what fails ... and we can probably point you in the right direction.
 
komaravolu raju
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for supporting.
You are right. I am simulating a data base for table in Random access files.
here is the model code.
I use '+' to denote the record exits, and '-' to denote the record is deleted.
Each attribute is of variable length.
the approach is like this:
while inserting a new record, +/- rollNoSize rollNo nameSize Name and.....
while listing the record, I have to check for =/- symbol and if it encounters +, display the data.
if it encounters -, skip till next =/- symbol is encountered.

so, I am able to write in the data to a file and list the '+' marked records. Once the '-' is encountered, I can't list the next records.
so, need help from here on.....


what is a fixed length record, how it has more advantages than variable length records???
Here is the code I have written..






more over when I am posting code, and I click on submit, I get an error message, abbreviation exists and what to do???
please resond as soon as possible...;
 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's more code than I want to read through. Can you post the whole text of the error message you're receiving? I'm not sure what "abbreviation exists" means. Also, I'm not sure what you mean when you say it happens when you're "posting code". Are you saying you get an error when you post code to this forum, or are we still talking about errors in your program?
 
komaravolu raju
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry.
I am not getting any error message when executing the program as of now.
As said in my reading and writing approach, ie., + & - symbols,

how to retrieve a particular record, and add '-' to it to indicate that the record is deleted..

 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This article on creating a low-level database with RandomAccessFile may interest you. Unless this is a homework assignment, in which case you should probably speak with your instructor.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!