0

我正在尝试读取生成的数据库 (*.jdb) 文件。

为了创建一个新数据库,我使用:

    storeConfig_ = new StoreConfig();
    storeConfig_.setAllowCreate(true);

我必须传入哪些 StoreConfig 参数才能读取已经存在的 *.jdb 文件?

4

1 回答 1

0
  1. 配置环境。
  2. 创建定义其位置的环境。
  3. 使用预定义的 DAO 创建新的 EntityStore。
  4. 然后您可以使用索引访问数据库。

    EnvironmentConfig envConfig = new EnvironmentConfig();
    
    try {
        myDbEnvironment_ = new Environment(new File(getDatabasePathString()), envConfig);
    } catch (DatabaseException e) {
        e.printStackTrace();
    }
    DAO.store_ = new EntityStore(environment, "EntityStore", new StoreConfig());
    Index_ = store_.getPrimaryIndex(String.class, Page.class);
    
于 2018-05-25T12:43:57.283 回答