The examples in this article describe Java connections and how to manipulate Sedna XML databases. Share to everyone for your reference. The specific analysis is as follows:
Sedna is a native XML database that provides full-featured core database services, including persistent storage, acid transactions, indexing, security, hot standby, UTF8, and more. Implements the standard for the XQuery specification, supports Full-text search, and node-level update operations.
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++;
}
}
}
I hope this article will help you with your Java programming.