【问题标题】:how to read existing jdb file java berkeley db如何读取现有的 jdb 文件 java berkeley db
【发布时间】:2018-05-22 13:04:32
【问题描述】:

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

为了创建我使用的新数据库:

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

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

【问题讨论】:

    标签: java berkeley-db-je


    【解决方案1】:
    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);
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-20
      • 2011-12-18
      • 1970-01-01
      相关资源
      最近更新 更多