Forum Stats

  • 3,769,977 Users
  • 2,253,041 Discussions
  • 7,875,257 Comments

Discussions

duplicatesAllowed configuration error

2702412
2702412 Member Posts: 1
edited Jun 26, 2014 8:19PM in Berkeley DB Java Edition

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.

Answers

  • Greybird-Oracle
    Greybird-Oracle Member Posts: 2,690

    > "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

This discussion has been closed.