⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transactionaldomtest.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of
// the Ozone Library License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
package test.xmldb.levelzero;

import org.w3c.dom.Document;
import org.xmldb.api.modules.TransactionService;
import org.xmldb.api.modules.XMLResource;
import test.xmldb.XMLDBTestCase;

/**
 * @author  Per Nyfelt
 */
public class TransactionalDOMTest extends XMLDBTestCase implements LevelZeroTestConstants {

    /** Creates new TransactionalDOMTest */
    public TransactionalDOMTest(String name) {
        super(name);
    }

    /**
     * test the transaction capabilities, this is optional for Core Level 1
     */
    public void testTransaction() {
        try {
            Document document1 = null;
            Document document2 = null;

            String id1 = "LevelZeroTest";
            String id2 = "LevelZeroTest2";
            transactionalInsertDOMDocument(id1, document1, id2, document2);

        } catch (Exception e) {
            fail( e.getMessage( ) );
        }
    }

   // Transaction support is optional for level 0 compliance
   private void transactionalInsertDOMDocument(String id1, Document document1,
                    String id2, Document document2) throws Exception {

        TransactionService transaction =
           (TransactionService) col.getService("TransactionService", "1.0");

        transaction.begin();

        XMLResource resource1 =
           (XMLResource) col.createResource(id1, XMLResource.RESOURCE_TYPE);

        resource1.setContentAsDOM(document1);
        col.storeResource(resource1);

        XMLResource resource2 =
           (XMLResource) col.createResource(id2, XMLResource.RESOURCE_TYPE);

        resource2.setContentAsDOM(document2);
        col.storeResource(resource2);

        transaction.commit();

   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -