Environment env = null;
Transaction txn = null;
Database db = null;
SecondaryDatabase secDb = null;
Cursor cursor = null;
JEConnection dc = null;
try {
dc = getConnection(JE_ENV);
env = dc.getEnvironment();
DatabaseConfig dbConfig = new DatabaseConfig();
SecondaryConfig secDbConfig = new SecondaryConfig();
dbConfig.setAllowCreate(true);
dbConfig.setTransactional(TRANSACTIONAL);
secDbConfig.setAllowCreate(true);
secDbConfig.setTransactional(TRANSACTIONAL);
secDbConfig.setKeyCreator(new MyKeyCreator());
/*
* Use JEConnection.openDatabase() to obtain a cached Database
* handle. Do not call close() on Database handles obtained
* using this method.
*/
db = dc.openDatabase("db", dbConfig);
secDb = dc.openSecondaryDatabase("secDb", db, secDbConfig);
System.out.println("blort");
cursor = db.openCursor(null, null);
cursor.put(new DatabaseEntry(key.getBytes()),
new DatabaseEntry(data.getBytes()));
} finally {
if (cursor != null) {
cursor.close();
}
if (dc != null) {
dc.close();
}
}
} catch (Exception e) {
System.err.println("Failure in put" + e);
}