Hi Isha,
Quote:
I dont use the same Database handle for both storing and retrieving the
data. I use to diffrent ones. The database needs to be open in both
cases as read and write operations happen simultaneously. |
Firstly, there is no reason why you couldn't use one Database handle,
and have some threads writing while other threads are reading. That
should work fine using just a single handle.
Using multiple Database handles, the problem is likely to be that they
are opened independently, so they share nothing. In particular, they
do not share a cache or lock manage. That means that each will read
and write the database file independently, so they will not see
consistent data, which is causing the errors you reported.
To resolve this, you will need to open an environment handle configured
with a cache and locking, then use Environment.openDatabase to open the
Database handles. The environment handle can be private to the process
(using EnvironmentConfig.setPrivate) if you don't want to manage an
environment directory on disk.
Quote:
If i use cursor.getFirst instead of cursor.getNext, this error does not
occur. Any ideas why this happens? |
It may be that the first page of the database happens to be on disk
when you read it with the second handle. The only way to make this
work in general is to have the two Database handles share a cache.
Regards,
Michael.