RecordStore of 1.5MB but getNumRecords returns 0

42 views
Skip to first unread message

eppie

unread,
Dec 19, 2012, 3:33:44 AM12/19/12
to java...@googlegroups.com
Hello,

At the moment I'm using a recordstore to store some measure values. At he moment I have a recordstore of 1.45MB but when I open it and call the method getNumRecords it returns 0. Is this an example of a corrupted recordstore?
Not any exception is trown.

Some code:
    private void openRecordStore() {
        Debug.log(System.out, "Opening recordstore...");
        this._recordAdministration = new Vector();

        try {
            
            String[] stores = RecordStore.listRecordStores();
            
            if(stores != null) {
                for(int i = 0; i < stores.length; ++i) {
                    Debug.log(System.out, "RecordStoreList --> Store: " + stores[i]);
                }
            }
            
            this._recordStore = RecordStore.openRecordStore(this._recordStoreName, true);
            Debug.log(System.out, "RecordStoreList --> number of records: " + this._recordStore.getNumRecords());
            RecordEnumeration re = this._recordStore.enumerateRecords(null, null, false);
            while (re.hasNextElement()) {                
                int recordId = re.nextRecordId();
                this._recordAdministration.addElement(new Integer(recordId));
            }
        } catch (Exception e) {
            Debug.log(System.out, "RecordStoreList --> EXCEPTION --> " + e.getMessage());
            e.printStackTrace();           
            closeRecordStore();
            deleteRecordStore();
            openRecordStore();
        }

        Debug.log(System.out, "Recordstore is open...");
    }


Thnx

ejw

unread,
Dec 19, 2012, 4:02:21 AM12/19/12
to java...@googlegroups.com
Hi,
 
I wouldn't be surprised if the store has corrupted.
 
Can you parse through the store?
 
If you have a serial connection and use the MES you might be able to see the record store on the A:\ drive and pul it onto your PC to inspect it.
 
I am not sure if anyone else here would agree with me, but record stores are really the last alternative for storage.
 
We have a set of variables that are default settings for all our systems, this is loaded on startup as an arrayfrom within the code, emergency data is stored as a txt file on the disk and called and read when required. The actual data we collect and transmit sits in a vector as it is only stored for less than a second.
 
ejw
Reply all
Reply to author
Forward
0 new messages