1 Reply Latest reply on Sep 26, 2012 12:24 PM by Charles Lamb

    Database creation


      I've got a strange problem, I've deleted the database directory but it seems the database handle is not garbage collection or something like that. As a matter of fact, I'm creating transaction-logs for a small storage solution. I don't want to open a few instances to remove the berkeleydb database from the environment and so on when invoking a simple "Database.truncateDatabase(DatabaseConfiguration)" in my application. However at some point I have to recreate the database with the same name and path. But BerkeleyDB somehow in some cases thinks the database is still there. I've managed to circumvent this by removing the database from the environment but strangely enough, while debugging I can see that BerkeleyDB now recognizes the database as newly created but somehow it doesn't create the database files in the folder specified by "mPlace":

                     // Create a new, transactional database environment.
                     final EnvironmentConfig config = new EnvironmentConfig();
                     config.setAllowCreate(true).setLocking(false).setCacheSize(1024 * 1024);
                     mEnv = new Environment(mPlace, config);

                     // Make a database within that environment.
                     final DatabaseConfig dbConfig = new DatabaseConfig();

                     removeExistingDatabase(NAME, mEnv);
                     mDatabase = mEnv.openDatabase(null, NAME, dbConfig);

      kind regards,
        • 1. Re: Database creation
          Charles Lamb
          I don't understand the exact scenario you are describing, but are you closing the Environment after you delete the database? Are you actually deleting the *.jdb files from the environment directory? I can't quite tell from your description.