Java API basics

You're back! Let's dive in. The first step to interacting with a MarkLogic database is to create an instance of the DatabaseClient class. Each of the example programs in this tutorial start with a step that looks something like this.

Notice the arguments passed to the factory method. As seen in the online javadoc for the newClient() method, these correspond to:

  • host — the host with the REST server
  • port — the port for the REST server
  • user — the user with read, write, or administrative privileges
  • password — the password for the user
  • type — the type of authentication applied to the request

For all of the sample apps in the project you downloaded, these parameters are configured using the Config.properties file:

If you want to see how the tutorial project extracts these properties, see its Config.java file.

Once you're done interacting with MarkLogic, you should always release the DatabaseClient:

The rest of this tutorial is about the things you might do in between creating the DatabaseClient and releasing it.

Setup

CRUD

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.