MongoDB.live, free & fully virtual. Register Now MongoDB.live, free & fully virtual. Register Now

Is the mongodb java driver based on JDBC?

Hi all,
Is the Mongodb JAVA driver based on JDBC ? or is it calling some a Mongodb rest api internally ?

[1] - https://mongodb.github.io/mongo-java-driver/4.1/

Thank you,
Dushan

I think the answer is “neither”. Looking at the code it makes pooled socket connections and carries out MongoDB-specific protocol exchanges

Thank you Jack! :slight_smile: that was helpful

1 Like

Hi @dushan_Silva,

MongoDB drivers communicate directly with a deployment using the MongoDB Wire Protocol. This is a socket-based, request-response style TCP/IP protocol using MongoDB-specific Database Commands. Driver API and behaviour is based on a set of standard MongoDB Specifications documented on GitHub.

JDBC is a higher-level API that was originally designed for tabular databases using SQL. In theory JDBC is database agnostic, with JDBC drivers providing translation between the JDBC API and the destination database protocol. Some of the API assumptions aren’t a great match for MongoDB, but there are several third party JDBC drivers available that try to bridge the gaps.

If you’re just getting started with MongoDB, I recommend using the official MongoDB Java Driver directly rather than adding abstraction layers and overhead.

MongoDB also has a Connector for BI which provides read-only access to query MongoDB using SQL, but the intended use case is for BI & reporting tools rather than application backends.

Can you provide some more context on your question: are you looking for a JDBC driver, just curious about how drivers communicate with the server, or something else?

Regards,
Stennie

1 Like