在Berkeley XMLDb中将内容从一个容器复制到另一个容器

时间:2017-08-10 06:12:17

标签: berkeley-db-xml

我需要在XML DB 2.5.16中将一些文档从一个容器复制到另一个容器。

以下是打开这些容器的代码段

public static void main(String[] args) throws DatabaseException {

    EnvironmentConfig config_1 = getEnvConfig();
    EnvironmentConfig config_2 = getEnvConfig();
    Environment dbEnv_1 =  new Environment(<dbEnvPath1>, config);
    Environment dbEnv_2 =  new Environment(<dbEnvPath2>, config_new);
    XmlManager mgr_1 = new XmlManager(dbEnv_1 ,getManagerConfig());
    XmlContainer cont_1 = mgr_1.openContainer(<containerName_1>, getContainerConfig());
    XmlManager mgr_2 = new XmlManager(dbEnv_2,getManagerConfig());
    XmlContainer cont_2 = mgr_2_new.openContainer(<containerName_2>, getContainerConfig());
}
private static EnvironmentConfig getEnvConfig() throws 
       DatabaseException{
    EnvironmentConfig config = new EnvironmentConfig();
    config.setErrorStream(System.err);
    config.setAllowCreate(true);
    config.setRunRecovery(true);
    config.setTransactional(true);
    config.setInitializeLocking(true);
    config.setInitializeLogging(true);
    config.setInitializeCache(true);
    config.setLogAutoRemove(true);
    config.setCacheSize(134217728);
    config.setMaxLocks(80000);
    config.setMaxLockers(4000000);
    config.setMaxLockObjects(80000);
    config.setMaxMutexes(86068);
    config.setMaxMutexes(70000);
    return config;
}
private static XmlManagerConfig getManagerConfig(){
    XmlManagerConfig mconfig = new XmlManagerConfig();
    mconfig.setAllowExternalAccess(true);
    return mconfig;
}
private static XmlContainerConfig getContainerConfig(){
    XmlContainerConfig cconfig = new XmlContainerConfig();
    cconfig.setAllowValidation(false); 
    cconfig.setTransactional(true);
    return cconfig;
}

运行此代码时,出现以下错误

  

PANIC:检测到致命区域错误;运行恢复       com.sleepycat.dbxml.XmlException:错误:DB_RUNRECOVERY:致命错误,运行       数据库恢复,errcode = DATABASE_ERROR at com.sleepycat.dbxml.dbxml_javaJNI.XmlManager_openContainerInternal__SWIG_0(Native   法)
      at com.sleepycat.dbxml.XmlManager.openContainerInternal(XmlManager.java:621)       在com.sleepycat.dbxml.XmlManager.openContainer(XmlManager.java:197)

1 个答案:

答案 0 :(得分:1)

尝试运行致命恢复,如此处的文档中所述: https://docs.oracle.com/cd/E17276_01/html/gsg_xml_txn/java/recovery.html

// Run catastrophic normal recovery
config.setRunFatalRecovery(true);