Skip to main content

Introduction

jdbc-mongo is an independent JDBC driver. Access MongoDB collections with commands for document reads and writes, aggregation and index management. Use Connection, PreparedStatement and ResultSet directly; dbVisitor APIs are optional.

Features​

  • Work with collections, documents and indexes, and run aggregation queries.
  • Bind parameters through PreparedStatement and use query options such as pagination and sorting.
  • Retrieve generated _id values, expand document fields and configure pre-reading.

Metadata Queries​

Query through connection.getMetaData():

JDBC methodResult
getCatalogs()Databases the current user can list
getTables()Collections and views
getColumns()Empty result; documents are not sampled to infer fields
getSchemas()Empty result
getTableTypes()TABLE, VIEW

Get Connected​

  1. Add dependencies: Maven or Gradle configuration.
  2. Connect to the database: JDBC URL, credentials and connection examples.
  3. Configure parameters: names, defaults and units.
  4. Usage limitations: JDBC support and database-specific restrictions.

Before You Connect​

  • Commands must use the syntax supported by this driver; arbitrary relational SQL is not translated.
  • JDBC batch and transactions are not supported. Check the shared JDBC limitations before integrating a connection pool, ORM or other JDBC tool.

Command reference · Query Operations · Data Writes