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
_idvalues, expand document fields and configure pre-reading.
Metadata Queries
Query through connection.getMetaData():
| JDBC method | Result |
|---|---|
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
- Add dependencies: Maven or Gradle configuration.
- Connect to the database: JDBC URL, credentials and connection examples.
- Configure parameters: names, defaults and units.
- 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.