當前位置: 首頁>>代碼示例>>Java>>正文


Java SequenceNotFoundException類代碼示例

本文整理匯總了Java中com.sleepycat.je.SequenceNotFoundException的典型用法代碼示例。如果您正苦於以下問題:Java SequenceNotFoundException類的具體用法?Java SequenceNotFoundException怎麽用?Java SequenceNotFoundException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SequenceNotFoundException類屬於com.sleepycat.je包,在下文中一共展示了SequenceNotFoundException類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: openSequence

import com.sleepycat.je.SequenceNotFoundException; //導入依賴的package包/類
/**
 * Opens or creates a sequence.
 * 
 * This method tries to open an existing sequence or create a new sequence with starting value
 * of the next available id number in the specified index.
 * 
 * @param entityStore The store that contains the sequence.
 * @param index The index which is used to initialize the starting value.
 * @param sequenceName The name of the sequence.
 * @return The opened or created sequence.
 */
public static Sequence openSequence(EntityStore entityStore, EntityIndex<Long, ?> index, 
        String sequenceName) {
    Sequence seq = null;
    try {
        seq = entityStore.getSequence(sequenceName);
    } catch (SequenceNotFoundException ex) {
        // Establish current value
        long initialValue = DatabaseUtils.getMaxId(index) +  1;

        entityStore.setSequenceConfig(sequenceName, 
                SequenceConfig.DEFAULT.setAllowCreate(true).setInitialValue(initialValue));
        seq = entityStore.getSequence(sequenceName);
    } finally {
        if (seq == null) {
            throw new RuntimeException("Could not open sequence localIdSequence.");
        }

        return seq;
    }
}
 
開發者ID:MTA-SZTAKI,項目名稱:longneck-bdb,代碼行數:32,代碼來源:DatabaseUtils.java

示例2: openSequence

import com.sleepycat.je.SequenceNotFoundException; //導入依賴的package包/類
/**
 * @see SecondaryDatabase#openSequence(Transaction, DatabaseEntry, SequenceConfig)
 */
public Sequence openSequence(final Transaction txn, final DatabaseEntry key,
                             final SequenceConfig config) throws SequenceNotFoundException,
        SequenceExistsException {
    return delegate().openSequence(txn, key, config);
}
 
開發者ID:jronrun,項目名稱:benayn,代碼行數:9,代碼來源:Berkeley.java


注:本文中的com.sleepycat.je.SequenceNotFoundException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。