Unsolved
This post is more than 5 years old
2 Posts
0
625
January 8th, 2009 07:00
Executing Xquery through java programming
Hi
I am using X-Hive/DB .I am trying to execute Xquery through java application.I can able to
retrieve the xml file from X-Hive/DB but when executing Xquery it throws error.The error statement is
java.lang.NoClassDefFoundError: org/antlr/runtime/RecognitionException
at xh8_1_3.yW.(xhive:49)
at xh8_1_3.ym.(xhive:62)
at xh8_1_3.ym.(xhive:45)
at xh8_1_3.vT.executeXQuery(xhive:1428)
at xh8_1_3.vT.executeXQuery(xhive:1404)
My xml file is
My java code is given below
I have use the above xquery in X-Hive/DB and it give me the results but i want to execute through java please provide me any solution.
I am using X-Hive/DB .I am trying to execute Xquery through java application.I can able to
retrieve the xml file from X-Hive/DB but when executing Xquery it throws error.The error statement is
java.lang.NoClassDefFoundError: org/antlr/runtime/RecognitionException
at xh8_1_3.yW.
at xh8_1_3.ym.
at xh8_1_3.ym.
at xh8_1_3.vT.executeXQuery(xhive:1428)
at xh8_1_3.vT.executeXQuery(xhive:1404)
My xml file is
"1.0" encoding="UTF-16"?>
"1">
Empire Burlesque
Bob Dylan
India
venkatesh
1000000
1983
My java code is given below
package samples.manual;
import java.util.Iterator;
import com.xhive.XhiveDriverFactory;
import com.xhive.core.interfaces.XhiveDatabaseIf;
import com.xhive.core.interfaces.XhiveDriverIf;
import com.xhive.core.interfaces.XhiveSessionIf;
import com.xhive.dom.interfaces.XhiveLibraryIf;
import com.xhive.query.interfaces.XhiveXQueryValueIf;
public final class XQuery {
private XQuery() {
}
public static void main(String[] args) {
String databaseName = SampleProperties.databaseName;
String administratorName = SampleProperties.administratorName;
String administratorPassword = SampleProperties.administratorPassword;
XhiveDriverIf driver = XhiveDriverFactory.getDriver("xhive://localhost:1235");
if(driver.isInitialized()){
System.out.println("Driver is already in connection");
}else{
driver.init(1024);
}
XhiveSessionIf session = driver.createSession();
try {
session.connect(administratorName, administratorPassword, databaseName);
session.begin();
XhiveDatabaseIf unitedNationsDb = session.getDatabase();
XhiveLibraryIf rootLibrary = unitedNationsDb.getRoot();
XhiveLibraryIf charterLib = DataLoader.createLibrary(unitedNationsDb, rootLibrary, "UN Charter", session);
String theQuery = " { for $b in doc('/UN Charter/book.xml')/catalog/cd return { $b/title } { $b/artist } } ";
System.out.println("#running query:\n" + theQuery);
Iterator result = rootLibrary.executeXQuery(theQuery);
// Process the results
while (result.hasNext()) {
XhiveXQueryValueIf value = (XhiveXQueryValueIf)result.next();
System.out.println(value.toString());
}
session.commit();
} catch (Exception e) {
System.err.println("XQuery sample failed: ");
e.printStackTrace();
} finally {
// disconnect and remove the session
if (session.isOpen()) {
session.rollback();
}
if (session.isConnected()) {
session.disconnect();
}
driver.close();
}
}
}
I have use the above xquery in X-Hive/DB and it give me the results but i want to execute through java please provide me any solution.
No Events found!



share4me
2 Posts
0
January 9th, 2009 06:00
in order to execute antlr-runtime-3.0.1.jar file should be mapped .