- Saved searches
- Use saved searches to filter your results more quickly
- License
- mongodb/mongo-jdbc-driver
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Mongodb java driver mongos
- Features
- Releases
- MongoDB University
- M220J: MongoDB for Java Developers
- MongoDB Java Driver
- Quick Start
- Quick Reference
- What’s New
- Usage Examples
- Fundamentals
- API Documentation
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
JDBC Driver for MongoDB Atlas SQL interface
License
mongodb/mongo-jdbc-driver
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
MongoDB Atlas SQL JDBC Driver
The MongoDB Atlas SQL JDBC Driver provides SQL connectivity to MongoDB Atlas for client applications developed in Java.
See the Atlas SQL Documentation for more information.
MongoDB Atlas SQL JDBC is a JDBC Type 4 driver compatible with the JDBC 4.2 specification.
MongoDB Atlas SQL JDBC driver requires Java 1.8 or higher.
You can download the precompiled driver (jars) from Maven Central.
Choose jar in the Download dropdown for the lean jar (dependencies not included) or all.jar for the fat jar (dependencies bundled inside the jar).
Connection URL and properties
The connection URL is based on MongoDB connection string and has the jdbc: prefix. The general format for the connection URL is as follows, with items in square brackets ([ ]) being optional:
jdbc:mongodb://[username:password@]host1[:port1][. hostN[:portN]][/[defaultauthdb][?option1=value1[&option2=value2]. ]
- Special characters in the JDBC url have to be URL encoded.
- The driver can not connect to a mongod instance, only to MongoDB Atlas.
All connection options can also be specified through a Properties object parameter instead of the being directly in the URL. However, if an option is in both the URL and the Properties object, the connection will fail.
In addition to the standard MongoDB connection options there are a number of additional properties specific to the JDBC driver.
These properties can only be specified using an additional Properties object parameter and not in the URL.
Property | Type | Required | Default | Description |
---|---|---|---|---|
database | String | Yes | Null | The name of the database used when querying |
loglevel | String | No | OFF | The log level used for logging. Supported levels by increasing verbosity are ‘OFF’, ‘SEVERE’, ‘WARNING’, ‘INFO’, ‘FINE’ and ‘FINER’ |
logdir | String | No | Null | The directory to use for log files. If no logging directory is specified, the logs are sent to the console |
The following example demonstrates how to open a connection specifying :
- The standard options user and password via a Properties object and ssl and authSource via the URL.
- The JDBC specific options database (mandatory) and loglevel via a Properties object.
java.util.Properties p = new java.util.Properties(); p.setProperty("user", "user"); p.setProperty("password", "foo"); p.setProperty("database", "test"); p.setProperty("loglevel", Level.SEVERE.getName()); System.out.println("Connecting to database test. "); Connection conn = DriverManager.getConnection("mongodb://mydatalake-xxxx.a.query.mongodb.net/?ssl=true&authSource=admin", p);
To build and test the driver run the following commands from root dir.
To build the lean jar which does not include the dependencies
To generate the source Jar
You can find the generated jar in build/libs/
To generate the fat Jar which includes all the dependencies
You can find the generated jar in build/libs/
You can find the generated jar in build/libs/
Integration testing requires a local MongoDB and Atlas Data Federation instance to be running
ADF_TEST_LOCAL_USER: Local ADF username
ADF_TEST_LOCAL_PWD: Local ADF password
ADF_TEST_LOCAL_AUTH_DB: Local ADF authentication database
HAVE_LOCAL_MONGOHOUSE: «1» if using local mongohouse source
LOCAL_MONGOHOUSE_DIR: Path to local mongohouse source
MDB_TEST_LOCAL_PORT (Optional): Local MongoDB port
To load integration test data
To generate integration test baseline configuration files
Running Local mongod and Atlas Data Federation
run_adf.sh is a helper script that will start a local mongod and Atlas Data Federation instance, used for integration testing.
Use the SKIP_RUN_ADF option to skip the start and stop operations for those managing their own local instances.
About
JDBC Driver for MongoDB Atlas SQL interface
Mongodb java driver mongos
The official MongoDB Java Drivers providing both synchronous and asynchronous interaction with MongoDB.
Features
BSON Library A standalone BSON library, with a new Codec infrastructure that you can use to build high-performance encoders and decoders without requiring an intermediate Map instance. MongoDB Driver An updated Java driver that includes the legacy API as well as a new generic MongoCollection interface that complies with a new cross-driver CRUD specification. MongoDB Reactive Streams Driver Providing asynchronous stream processing with non-blocking back pressure for MongoDB. Fully implements the Reactive Streams API for providing interop with other reactive streams within the JVM ecosystem.
From 4.0 documentation for the MongoDB Java Reactive Streams Driver is available here, alongside all the JVM drivers. For 1.x documentation see the old Reactive Streams Java Driver documentation. MongoDB Scala Driver Providing idiomatic Scala support for MongoDB.
From 4.0 documentation for the MongoDB Scala Driver is available here, alongside all the JVM drivers. For 2.x documentation see the old Scala Driver documentation.
Releases
Release | Documentation |
---|---|
4.10.0 | Reference | API |
4.9.0 | Reference | API |
4.8.0 | Reference | API |
4.7.2 | Reference | API |
4.6.0 | Reference | API |
4.5.1 | Reference | API |
4.4.1 | Reference | API |
4.3.4 | Reference | API |
4.2.3 | Reference | API |
4.1.2 | Reference | API |
4.0.6 | Reference | API |
3.12.14 | Reference | API |
3.11.3 | Reference | API |
3.10.2 | Reference | API |
3.9.0 | Reference | API |
3.8.2 | Reference | API |
3.7.1 | Reference | API |
3.6.4 | Reference | API |
3.5.0 | Reference | API |
3.4.3 | Reference | API |
MongoDB University
M220J: MongoDB for Java Developers
Learn the essentials of Java application development with MongoDB.
Copyright © 2008-present MongoDB, Inc. MongoDB, Mongo, and the leaf logo are registered trademarks of MongoDB, Inc.
MongoDB Java Driver
, or set up a runnable project by following our Quick Start guide.
If your Java application requires asynchronous stream processing, use the Reactive Streams Driver which uses Reactive Streams to make non-blocking calls to MongoDB.
Quick Start
Learn how to establish a connection to MongoDB Atlas and begin working with data in the Quick Start section.
Quick Reference
See driver syntax examples for common MongoDB commands in the Quick Reference section.
What’s New
For a list of new features and changes in each version, see the What’s New section.
Usage Examples
For fully runnable code snippets and explanations for common methods, see the Usage Examples section.
Fundamentals
Learn how to perform the following tasks using the Java driver in the Fundamentals section:
- Connect to MongoDB
- Use the Stable API
- Authenticate with MongoDB
- Convert between MongoDB Data Formats and Java Objects
- Read from and Write to MongoDB
- Simplify your Code with Builders
- Transform your Data
- Create Aggregation Expressions
- Create Indexes to Speed Up Queries
- Sort Using Collations
- Log Events in the Driver
- Monitor Driver Events
- Store and Retrieve Large Files in MongoDB
- Encrypt Fields in a Document
- Use a Time Series Collection
API Documentation
The MongoDB Java driver API documentation contains several libraries organized by functionality. For detailed information about classes and methods in each library, see the following table for their descriptions and links to the API documentation.