Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing the database file - alternatives to singleton (?)

 
Jaro Simak
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see any possibility than to create a single instance of class that
wrapps RandomAccessFile (all method have to be synchronized) to access the
database file. There is only one file and access from multiple instances could
lead to a corrupted database (for instance 2 threads creates new record at the
end of file).

Do you have another opionion?
Greetings Jaro
 
Seb Mathe
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This solution is ok but is the most restrictive regarding concurrent access to the database.

Why not have multiple RAF instances ?

Why not permit "simultaneous" updates on different records ?

...

As you said, we have to take care of DB integrity, so we must pay more attention when using less restrictive solutions.

Personnaly, I don't like the idea of one RAF / all synchronized but it's certainly a valuable solution which can be explained by its simplicity.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic