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.