aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes DB Create/Update/Delete Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "DB Create/Update/Delete" Watch "DB Create/Update/Delete" New topic
Author

DB Create/Update/Delete

Tim Fernandez
Ranch Hand

Joined: Aug 31, 2005
Posts: 65
Hi All,

DO you think this approach is ok?

Create -> add record at the bottom or replace a deleted record
Update -> delete record (set delete flag to 1) and add updated record
Delete -> delete record (set delete flag to 1)

regards,
Tim
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
hi tim,

maybe i'm overlooking something, but i cannot see why you should want to split "update" into "delete" & "create" (assuming that your lock mechanism works ... ;-) )
a simple lock-change-unlock will do the same, don't you think?

plus (better: minus): an updated record can have a new number / position in the data file. this would make the algorithm unneccesary complicated. you'll be glad about consistent record numbers when it comes to gui-handling...

the rest is okay, obviously.

many greetings,
jan
Tim Fernandez
Ranch Hand

Joined: Aug 31, 2005
Posts: 65
Hi Jan,

Thanks for the reply!
If this is the case,then im gonna do something
like this instead,

readByte(); for the flag
writeBytes(String) -> Does this overwrite the existing
string in the file or does it insert this to the file and move
the existing ones to another location in the file?

regards,
Tim
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
hi tim,

well, i used a RandomAccessFile, it's pretty simple: you jump to a position and write the next bytes, overwritting whatever was there before.

i'm sure there are different ways, but i found this one most suitable ;-)

greetings,
jan
Tim Fernandez
Ranch Hand

Joined: Aug 31, 2005
Posts: 65
Thanks Jan,

Yah, I tried using RandomAccessFile and it overwrites it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DB Create/Update/Delete