Establishing a Connection
Creating a JDBC Data Source
You can create a JDBC data source to connect from your Java application, based on CData JDBC Driver for MarkLogic.Follow these steps:
- Add the driver JAR file to the classpath. The JAR file is located in the installation directory's lib subfolder. Ensure that the .lic file is located in the same folder as the JAR file.
- Provide the driver class. For example:
cdata.jdbc.marklogic.MarkLogicDriver
- Provide the JDBC URL. For example:
jdbc:marklogic:User='myusername';Password='mypassword';Server='marklogic'
Or, if there is a conflict in your application between drivers using the same URL format, use this form to ensure that you are using the CData driver:
jdbc:cdata:marklogic:User='myusername';Password='mypassword';Server='marklogic'
Ensure that the URL starts with either jdbc:marklogic: or jdbc:cdata:marklogic:. The URL can include any of the connection properties in name-value pairs separated with semicolons.
Connecting to MarkLogic
Picking an API
The CData JDBC Driver for MarkLogic offers access to both the REST and ODBC APIs for MarkLogic. Please see Picking the right API for a discussion on which API is right for your use case.
Connection Details
Regardless of which API you are connecting to, you will need to include the following connection details:
- Server - The server being connected to.
- Database - (Optional) The specific database to connect to.
- Port - (Optional) The specific port to use if the default port for the selected API is not being used default.
Create an ODBC Server
If connecting to the ODBC API, please follow the guide in MarkLogic's official website on how to create an ODBC Server, https://docs.marklogic.com/guide/admin/odbc.
Authenticating to MarkLogic
To authenticate to MarkLogic, specify the following connection properties: