欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Java連接并操作Sedna XML數(shù)據(jù)庫的方法

 更新時間:2015年06月29日 10:22:52   作者:紅薯  
這篇文章主要介紹了Java連接并操作Sedna XML數(shù)據(jù)庫的方法,較為詳細(xì)的說明了Sedna XML數(shù)據(jù)庫的原理與功能,并給出了基于java操作Sedna XML數(shù)據(jù)庫的方法,需要的朋友可以參考下

本文實(shí)例講述了Java連接并操作Sedna XML數(shù)據(jù)庫的方法。分享給大家供大家參考。具體分析如下:

Sedna 是一個原生的XML數(shù)據(jù)庫,提供了全功能的核心數(shù)據(jù)庫服務(wù),包括持久化存儲、ACID事務(wù)、索引、安全、熱備、UTF8等。實(shí)現(xiàn)了 W3C XQuery 規(guī)范,支持全文搜索以及節(jié)點(diǎn)級別的更新操作。

import ru.ispras.sedna.driver.*; 
public class SednaClient { 
 public static void main(String args[]) { 
  SednaConnection con = null; 
  try { 
   /* Get a connection */ 
   con = DatabaseManager.getConnection("localhost", 
                     "testdb", 
                     "SYSTEM", 
                     "MANAGER"); 
   /* Begin a new transaction */ 
   con.begin(); 
   /* Create statement */ 
   SednaStatement st = con.createStatement(); 
   /* Load XML into the database */ 
   System.out.println("Loading data ..."); 
   boolean res; 
   res = st.execute("LOAD 'C:/region.xml' 'region'"); 
   System.out.println("Document 'region.xml' "+ 
     "has been loaded successfully"); 
   /* Execute query */ 
   System.out.println("Executing query"); 
   res = st.execute("doc('region')/*/*"); 
   /* Print query results */ 
   printQueryResults(st); 
   /* Remove document */ 
   System.out.println("Removing document ..."); 
   res = st.execute("DROP DOCUMENT 'region'"); 
   System.out.println("Document 'region' " + 
         "has been dropped successfully"); 
   /* Commit current transaction */ 
   con.commit(); 
  } 
  catch(DriverException e) { 
    e.printStackTrace(); 
  } 
  finally { 
   /* Properly close connection */ 
   try { if(con != null) con.close(); } 
   catch(DriverException e) { 
    e.printStackTrace(); 
   } 
  } 
 } 
 /* Pretty printing for query results */ 
 private static void printQueryResults(SednaStatement st) 
  throws DriverException { 
  int count = 1; 
  String item; 
  SednaSerializedResult pr = st.getSerializedResult(); 
  while ((item = pr.next()) != null) { 
   System.out.println(count + " item: " + item); 
   count++; 
  } 
 } 
}

希望本文所述對大家的java程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論