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

RandomAccessFile

 
Jesse Jesse
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a simple question and am looking for some advice. I am using a RandomAccessFile in my Database class(Data) to directly access the db file for each request. Would it be better to have this class as a private instance member, static member of my Database class or create an instance of it for each data access request? I suppose it boils down to which way I implement my networking layer in that if I use a singleton database then all clients will use the same database instance or if I create a database instance to service each client.

Thanks

Mark
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi McManus
this is a good question. In RDB I create a new connection in every method, and that is because disk access delay while ths SQL statement is being compiled.
I followd the same technique with my RAF. I creats a new instance in each method, but I am not sure 100% if it is the way to go. Becuase there is non compilation of search parameters, and hence maybe it will not make differnce.
I just feel it is better this way, so that there will be no race on resources.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic