Powered by Zoomin Software. For more details please contactZoomin

Develop with XCC

Coding Basics

  • Last Updated: January 16, 2026
  • 1 minute read
    • MarkLogic Server
    • Version 11.0
    • Documentation

To use XCC, there are several basic things you need to do in your Java code:

  1. Import the needed libraries.

  2. Set up the ContentSource object to authenticate against MarkLogic Server.

  3. Create a new Session object.

  4. Add a Request to the session object.

  5. Submit the request and get back a ResultSequence object from MarkLogic Server.

  6. Do something with the results (print them out, for example).

  7. Close the session.

The following are Java code samples that illustrate these basic design patterns:

package com.marklogic.xcc.examples;
import com.marklogic.xcc.ContentSource;
import com.marklogic.xcc.ContentSourceFactory;
import com.marklogic.xcc.Session;
import com.marklogic.xcc.Request;
import com.marklogic.xcc.ResultSequence;
URI uri = new URI("xcc://user:pass@localhost:8000/mycontent");
ContentSource contentSource = 
          ContentSourceFactory.newContentSource (uri);
Session session = contentSource.newSession();
Request request = session.newAdhocQuery ("\"Hello World\"");
ResultSequence rs = session.submitRequest (request);
System.out.println (rs.asString());
session.close();

Note: Session objects are not thread safe. A Session object should not be used concurrently by multiple threads.

TitleResults for “How to create a CRG?”Also Available inAlert