Esta página describe cómo instalar y configurar MongoDB JDBC or ODBC drivers for connecting your BI tool to your Atlas or self-managed Enterprise Advanced (EA) database.
Reference the table below to find the correct driver for your BI tool.
Controlador | BI Tool |
|---|---|
Controlador JDBC | Tableau Desktop or Server or other JDBC-supported tools such as DBeaver, DataGrip, or a Maven project. |
Controlador ODBC | Power BI Desktop or other ODBC-supported tools such as Excel. |
Nota
MongoDB officially supports Tableau (Desktop or Server) and Power BI Desktop (Desktop and Service) with its JDBC and ODBC drivers. You can use the JDBC and ODBC drivers with other SQL-92 BI tools, but MongoDB cannot guarantee compatibility. Test your specific SQL Interface features to confirm support.
Install the JDBC Driver
The MongoDB JDBC driver is required for connecting to your database with Tableau, DBeaver, DataGrip, and other Java applications that accept a JDBC API, such as a Maven project.
JDBC Driver Compatibility
The MongoDB JDBC driver is compatible with:
Ventanas x86_64
Arquitecturas macOS x86_64 y macOS aarch64
linux x86_64 y arquitecturas linux arm64
Se requiere OpenSSL 3.0 o superior para conexiones seguras.
Puede autenticarse con SCRAM-SHA-,1 SCRAM-SHA-,256 MONGODB-X509 y autenticación sin contraseña de MongoDB con AWS.
Procedimiento
Download the MongoDB JDBC driver.
Download the latest JDBC driver from the MongoDB download center.
Nota
The JDBC driver is available in two jar formats:
mongodb-jdbc-<version>-all.jarContiene el controlador y todas las dependencias necesarias. Necesario para Tableau y DBeaver.mongodb-jdbc-<version>.jarcontiene el controlador sin dependencias integradas. Se requiere para las herramientas de JetBrains.
Move the jar file to the appropriate directory for your operating system.
Copy the jar file to the appropriate directory for your BI tool. For example, if you're installing the JDBC driver for Tableau:
Windows:
C:\Program Files\Tableau\DriversmacOS:
~/Library/Tableau/DriversLinux:
/opt/tableau/tableau_driver/jdbc
Verificar la integridad del paquete descargado.
El equipo de lanzamiento de MongoDB firma digitalmente todos los paquetes de software para certificar que cada paquete de MongoDB es una versión válida e inalterada. MongoDB firma cada rama de lanzamiento con una clave PGP diferente en formato .asc.
Ejecuta el siguiente comando para descargar el archivo
.ascdesde el Repositorio Central de Maven. Reemplaza<versionNumber>con la versión del driver que descargaste y<artifactToVerify>con el nombre del archivo que descargaste.curl -O https://repo1.maven.org/maven2/org/mongodb/mongodb-jdbc/<versionNumber>/<artifactToVerify>.asc Por ejemplo, si descargaste
mongodb-jdbc-2.2.3-all.jar, deberás ejecutar el siguiente comando.curl -O https://repo1.maven.org/maven2/org/mongodb/mongodb-jdbc/2.2.3/mongodb-jdbc-2.2.3-all.jar.asc Ejecuta el siguiente comando para descargar y luego importar el archivo de clave. Reemplace
<serverUrl>por uno de los servidores de claves GPG actuales compatibles con Maven:keyserver.ubuntu.comkeys.openpgp.orgpgp.mit.edu
gpg --keyserver <serverUrl> --recv-keys BDDC8671F1BE6F4D5464096624A4A8409351E954 gpg: key BDDC8671F1BE6F4D5464096624A4A8409351E954: public key "MongoDB JDBC Driver Release Signing Key <packaging@mongodb.com>" imported gpg: Total number processed: 1 gpg: imported: 1 Run the following command to verify the MongoDB JDBC driver installation file. Replace
<detachedSignatureFile>and<artifactToVerify>with the names of the files you downloaded.gpg --verify <detachedSignatureFile> <artifactToVerify> Por ejemplo, si descargó
mongodb-jdbc-2.2.3-all.jarymongodb-jdbc-2.2.3-all.jar.ascen su directorio actual, ejecute lo siguiente.gpg --verify mongodb-jdbc-2.2.3-all.jar.asc mongodb-jdbc-2.2.3-all.jar GPG debería devolver una respuesta similar a la siguiente:
gpg: Signature made Wed May 22 13:24:36 2024 MDT gpg: using RSA key BDDC8671F1BE6F4D5464096624A4A8409351E954 gpg: Good signature from "MongoDB JDBC Driver Release Signing Key <packaging@mongodb.com>" Si el paquete está firmado correctamente, pero aún no confía en la clave de firma en su
trustdblocal,gpgtambién devolverá el siguiente mensaje:gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: D2C4 5B7E 66A5 DCA1 8B76 57A8 91A2 1577 3066 6110 Si recibe el siguiente mensaje de error, confirme que haya importado la clave pública correcta:
gpg: Can't check signature: public key not found
Integrate with a Maven Project
If you use Atlas Data Federation, you can connect the MongoDB JDBC driver with your Maven application.
Configure el controlador para su aplicación Maven.
Copy the dependency snippet from the Maven Central Repository. Edit the version number in the dependency snippet to match your JDBC driver version.
Por ejemplo:
<dependency> <groupId>org.mongodb</groupId> <artifactId>mongodb-jdbc</artifactId> <version>2.1.0</version> </dependency>
Agregue la dependencia a su proyecto Maven.
En el archivo pom.xml de su proyecto, pegue el fragmento en la lista de dependencias de la siguiente manera:
<dependencies> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongodb-jdbc</artifactId> <version>2.1.0</version> </dependency> </dependencies>
Conéctese a su instancia de base de datos federada.
To connect to your federated database instance, create a connection string and open a connection from your application. The connection string for the JDBC driver follows the format of the standard MongoDB connection string, except with the jdbc: prefix:
jdbc:mongodb://[username:password]@[host].a.query.mongodb.net/<databaseName>[?option1=value1[&option2=value2]...]
To get the connection string from the Atlas UI, do the following:
In the Atlas UI, go to the Data Federation page and click Connect for the federated database instance that you want to connect to.
En Access your data through tools, selecciona Atlas SQL.
En Select your driver, selecciona JDBC Driver en el menú desplegable.
En Get Connection String, seleccione la base de datos a la que desea conectarse y copie la cadena de conexión.
El siguiente ejemplo demuestra cómo abrir una conexión. Además de la cadena de conexión, debe especificar también la base de datos a usar a través de un parámetro objeto Properties. Para aprender más, consulta Cadenas de Conexión y Propiedades de Conexión.
java.util.Properties p = new java.util.Properties(); p.setProperty("database", "<databaseName>"); Connection conn = DriverManager.getConnection("<connectionString>", p);
Nota
The driver can only connect to Atlas and not to a federated database instance. Any special characters in the connection string for the JDBC driver must be URL encoded.
Install the ODBC Driver
The MongoDB ODBC driver is required for connecting to your database with Power BI, Excel, or other ODBC-supported BI tools.
Choose your deployment type to get started:
Próximos pasos
After you have installed the correct driver for your BI tool, connect your BI tool to your database.