0

I have the following java code. I am using XQJ to write a test XQuery program using XQJ api. I have downloaded JSR-000225 XQuery API for Java 1.0 Final Release, and added xqjapi.jar to my classpath. The java code is as simple as the following

import javax.xml.xquery.XQConnection;
import javax.xml.xquery.XQDataSource;
import javax.xml.xquery.XQException;

public class SaxonExtJavaObject {

public static void main(String[] args) throws XQException, InstantiationException,       IllegalAccessException, ClassNotFoundException {

  XQDataSource xqds = (XQDataSource)
          Class.forName("com.jsr225.xqj").newInstance();

       // obtain a connection
       XQConnection con = xqds.getConnection("usr", "passwd");
       System.out.println("connected");
}
}

My problem is that I have the following exception

   Exception in thread "main" java.lang.ClassNotFoundException: com.jsr225.xqj
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

Please some one help me solving this.

splungebob
  • 5,357
  • 2
  • 22
  • 45
Lucy
  • 471
  • 4
  • 12
  • 28

1 Answers1

3

you will still need a product (i.e. XQuery processor) acting as an actual data source; you can find a list of supported implementations on http://xqj.net/

Much like JDBC, despite having an interface defining the operations allowed with a database, you need an implementation (e.g. MySQL, PostgreSQL or DB2) that carries out the selected tasks.

There are XQJ implementations for XML Databases written in Java: BaseX, eXist
as well as interfaces to Zorba, MarkLogic (commercial) and Sedna (written in C/C++).

In your example you reference Saxon, information on using Saxon and XQJ can be found in Saxon’s documentation

I hope this helped to clear things up a litte.

Michael

michael
  • 1,577
  • 1
  • 12
  • 18
  • 1
    Michael, you probably don't know this yet, but zorba (C++) also provides an XQJ API: http://www.zorba-xquery.com/html/documentation/2.5.0/xqj ;) – Dennis Münkle Jul 06 '12 at 14:22
  • Dennis, whoops, sorry sure I know; I just failed to remember (updated my answer!) – michael Jul 06 '12 at 18:12
  • Thanks for your answer, but I really need to use saxon, I jave downloaded saxon9.jar and introduced it to the classpath. The problem is not fixed yet. I have updated the code, now the imports are import org.w3c.dom.Document; import org.w3c.dom.Node; import org.xml.sax.InputSource; import net.sf.saxon.javax.xml.xquery.XQConnection; import net.sf.saxon.javax.xml.xquery.XQException; import net.sf.saxon.xqj.SaxonXQDataSource; and the DataSource definitions is XQDataSource xqds = new SaxonXQDataSource(); but it doesn't recognize any of the imports. any Idea please? – Lucy Jul 06 '12 at 18:17