Search in sources :

Example 1 with DuplicateEntryException

use of com.sleepycat.je.tree.DuplicateEntryException in project leopard by tanhaichao.

the class BdbDatabaseImpl method putNoDupData.

@Override
public boolean putNoDupData(String key, String value) throws DatabaseException {
    OperationStatus status = database.putNoDupData(transaction, new DatabaseEntry(key.getBytes()), new DatabaseEntry(value.getBytes()));
    String result = status.toString();
    if (result.endsWith(".KEYEXIST")) {
        throw new DuplicateEntryException("key[" + key + "]已存在.");
    }
    // System.err.println(status);
    return true;
}
Also used : OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry) DuplicateEntryException(com.sleepycat.je.tree.DuplicateEntryException)

Example 2 with DuplicateEntryException

use of com.sleepycat.je.tree.DuplicateEntryException in project leopard by tanhaichao.

the class IdTransverterBdbImpl method add.

@Override
public boolean add(String tableName, String id, String newId) {
    try {
        Bdb database = bdb.getDatabase(tableName);
        System.err.println("add tableName:" + tableName + " id:" + id);
        return database.putNoDupData(id, newId);
    } catch (DuplicateEntryException e) {
        logger.warn(e.getMessage());
        return false;
    } catch (DatabaseException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : Bdb(io.leopard.bdb.Bdb) DuplicateEntryException(com.sleepycat.je.tree.DuplicateEntryException) DatabaseException(com.sleepycat.je.DatabaseException)

Aggregations

DuplicateEntryException (com.sleepycat.je.tree.DuplicateEntryException)2 DatabaseEntry (com.sleepycat.je.DatabaseEntry)1 DatabaseException (com.sleepycat.je.DatabaseException)1 OperationStatus (com.sleepycat.je.OperationStatus)1 Bdb (io.leopard.bdb.Bdb)1