This discussion is archived
1 Reply Latest reply: Sep 26, 2012 5:24 AM by Charles Lamb RSS

Database creation

921522 Newbie
Currently Being Moderated
Hello,

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();
               dbConfig.setAllowCreate(true).setExclusiveCreate(false)
                         .setDeferredWrite(true);

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

kind regards,
johannes
  • 1. Re: Database creation
    Charles Lamb Pro
    Currently Being Moderated
    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.

    Charles

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points