• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

deleting record stores

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is is it possible to have multiple instances of a record store open at once? I'm trying to delete a record store using the following code:

The first line of code obtains an instance of the record store. The second line of code closes the record store since this must be done before deleting it. I also verified (using a print out statement) that the close method is closing the record store named removeName as it should. The close method appears to work fine as it does not return any exception. The deleteRecordStore method, however, always returns an exception stating the record store has not been closed.
If anyone knows why there would be an exception stating the record store is still open after explicitly closing it in previous line of code, please let me know.
Thanks!
Greg
 
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you opened the store multiple times, you have to have a matching number of close() clause to actualy close it.
cheers
Michael
 
Greg Schwartz
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael -
Thanks so much for that info! That was definitely what I was doing wrong. Do you know if there is anyway to determine how many times an instance of a RecordStore has been opened so you know how many times it needs to be closed?
Also, do you know of a way around opening the record store multiple times?
In my case, a user has multiple accounts of information. I have one RecordStore that stores the account names and is only opened once. I then have a RecordStore (myDB in the above code example) that is opened when a user selects a certain account by passing the account name to the RecordStore's openRecordStore method. Everytime a user switches accounts the openRecordStore method is used to get an instance of that account. This results in the situation where multiple closes are needed when the account is removed by the user.
Thanks again for your help!
Greg
 
Michael Yuan
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Greg,
Without knowing the specific details of your program, I can only be very general. I think you can have a boolean tracking variable that goes with each record store. Set the tracker to "true" when you open the store. The reference to the store and the tracker should both be public accessible. Now, before you open the store, you always check the tracker to see if it is already opened. If so, you can just reuse the existing reference ...
 
reply
    Bookmark Topic Watch Topic
  • New Topic