• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

B&S: find() and locking records for reterival

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Find() in the DBMain interface returns int[]... as users we are interested in the actual records not the record numbers of course... so the algorethim would be something like this:
1. in the business layer the user invokes search()
2. search() invokes find() and get int[]
3. search() starts reterieving recrods returned from find()

here is the problem: WHAT IF the CPU decides that another thread should run after step 2, and that thread is changing one of the records (for example changing the name of the contractor) that happen to be returned by find().
the user issued the search might end up with record(s) that don't match his/her criteria.

Ideas ?

Thanks
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Musab,

The same problem was discussed at this post, give it a look.

To resume, the idea is to re-validate each record when you retrieve it after the find() method.

Jar
reply
    Bookmark Topic Watch Topic
  • New Topic