Java MapDB: how to handle "already open" exception?

791 Views Asked by At

I am new in using MapDB in Java.

import org.mapdb.*;

void foo ()
{
  DB db = DBMaker.fileDB ("map.db").make ();

  // some code

  db.close ();
}

If the program crashed in "some code", then the make () would throw an exception.

File is already opened and is locked: map.db

How can I handle this? There must be a way where the program can crash and I can unlock the MapDB without deleting it (between different program-starts as well as between different foo-calls).

The question is not about exception-handling and avoiding a crash! There are always situations where the DB will not be closes securely (e.g. poweroff, kernel, JVM, ...).

Thanks!

0

There are 0 best solutions below