1 Reply Latest reply: Jun 26, 2014 7:19 PM by Greybird-Oracle RSS

    duplicatesAllowed configuration error

    c4b70f48-ac73-4893-b863-5243408feb39

      I am newbie to Berkely DB.I have written a simple program to read and write from the DB and use secondary database.

      when i run this code the following error occur

      "You can't open a Database with a duplicatesAllowed configuration of true if the underlying database was created with a duplicatesAllowedSetting of false"


          public LocalDataBase(String homeDir) throws DatabaseException, FileNotFoundException{

              EnvironmentConfig conf = new EnvironmentConfig();

              conf.setTransactional(true);

              conf.setAllowCreate(true);

              env = new Environment(new File(homeDir), conf);

             

              DatabaseConfig  dbConf = new DatabaseConfig();

              dbConf.setTransactional(true);

              dbConf.setAllowCreate(true);

              Database catdb = env.openDatabase(null, CLASS_CATALOG, dbConf);

              javaCatalog = new StoredClassCatalog(catdb);

             

              metadataDb = env.openDatabase(null, METADATA_STORE, dbConf);

             

                // begin of secondary section

              SecondaryConfig secConf = new SecondaryConfig();

              secConf.setTransactional(true);

              secConf.setAllowCreate(true);

              secConf.setSortedDuplicates(true);

             

              secConf.setKeyCreator(new MetsdataSecondaryKeyCreator(

                          this.javaCatalog, MetadataKey.class,

                          MetadataValue.class, String.class));

              metadataByUserAndKeyDb = env.openSecondaryDatabase(null,

                      METADATA_SECONDARY_INDEX, metadataDb, secConf);

                // end of secondary section

          }

       

      notice: this is true without socondary section

      please help me.

        • 1. Re: duplicatesAllowed configuration error
          Greybird-Oracle

          > "You can't open a Database with a duplicatesAllowed configuration of true if the underlying database was created with a duplicatesAllowedSetting of false"


          This means you created the database (opened it for the first time) without calling setSortedDuplicates(true).  You can't change this setting for an existing database.  If you're just testing, remove your environment (delete all the .jdb files) and start over.  If this is a production issue, you'll have to remove the database with Environment.removeDatabase.


          --mark