Skip to content
bobstarbird edited this page Apr 15, 2019 · 5 revisions

Making JDBC connections to MarkLogic SQL/ODBC Server

Note Bene

This project and its code and functionality is not representative of MarkLogic Server and is not supported by MarkLogic. This is not a MarkLogic product, but is an unsupported, unofficial tool developed by MarkLogic consultants in the field. You should test it in a development environment thoroughly before depending on it in production.

If possible you should use the ODBC drivers supported by MarkLogic. If you can only use JDBC (because for example the tool only supports JDBC) then you have two options for drivers. You have a choice of using the JDBC driver from PostgreSQL with no modifications postgresql-42.1.4.jar or the enhanced driver mljdbc-42.1.4.jar contained in this project.

B.L.U.F. (Bottom Line Up Front)

A JDBC type 4 driver can be used to connect to the read only MarkLogic ODBC server. The PostgreSQL JDBC driver supports SQL queries to MarkLogic Server from a wide variety of clients. This project modifies the PostgreSQL driver to provide additional support for MarkLogic metadata functions. The metadata functions allow a client to ask for a list of schemas, tables and columns for reporting and data type mappings from SQL to Java. This driver provides read-only access to SQL views built in MarkLogic using the Template Drive Extraction (TDE) feature. See MarkLogic's SQL Modeling Guide for more details on constructing TDE views compatible with this JDBC Driver at https://docs.marklogic.com/guide/sql.

tl;dr (too long; didn't read)

mljdbc-42.1.4.jar
Driver Name: "com.marklogic.Driver"
Driver URL: "jdbc:marklogic://localhost:8077/"

Example: https://github.com/marklogic-community/ml-gradle/wiki/JDBC

Setup

First Setup an ODBC application server in MarkLogic.

Then Download:

MarkLogic JDBC 4.2 Driver, 42.1.4

https://github.com/marklogic-community/ml-jdbc-driver/blob/v0.3-beta/mljdbc-42.1.4.jar

or

PostgreSQL JDBC 4.2 Driver, 42.1.4

https://jdbc.postgresql.org/download/postgresql-42.1.4.jar

Be sure to use the specific driver version. Be sure to include the jar in your classpath.

Next Configure the connection driver name (aka Class.forName) and the connection string URL: jdbc:<vendor>://<host>:<port>/

Driver Name: "com.marklogic.Driver"
Driver URL: "jdbc:marklogic://localhost:8077/"

or

Driver Name: "org.postgresql.Driver"
Driver URL: "jdbc:postgresql://localhost:8077/?preferQueryMode=simple"