当前位置: 首页>>代码示例>>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;未经允许,请勿转载。