JDBC Driver for MongoDB

Build 24.0.9060

DbVisualizer

This section shows how to establish a connection to data in DbVisualizer, use the table editor to edit and save data, and execute SQL.

Add the JDBC Driver for MongoDB

Complete the following steps to add the driver .jar file in a driver definition:

  1. In the DbVisualizer toolbar, select Tools > Driver Manager.
  2. Click the "+" button in the top-left corner of the Driver Manager window and select Custom.
  3. Enter a name for the driver.
  4. Enter the following in the URL Format box:
    jdbc:mongodb:
  5. In the Driver artifacts and jar files section, click the "+" button on the right and select Add Files... to browse for the driver .jar file, cdata.jdbc.mongodb.jar. By default, this is located in the lib subfolder of the installation directory. Note that the .lic file in this folder must be located in the same folder as the .jar file.
  6. In the Driver Class menu, select the MongoDBDriver class, cdata.jdbc.mongodb.MongoDBDriver.

Create a Database Connection for MongoDB

Complete the following steps to select the MongoDB driver and build the JDBC URL to create the JDBC data source:

  1. In the DbVisualizer toolbar, select Database > Create Database Connection. The Driver Name selector will then appear.

    Note: If this option is greyed out, you may need to first select the Connections root element of the tree view, found in the Databases tab of the left-hand pane.

  2. Double-click the name of the JDBC driver you defined in the section above.
  3. Set Settings Format to Database URL if it isn't already set to that value.
  4. Set Driver Type to the name you defined for your JDBC driver, if it doesn't default to that name.
  5. Set Database URL to the full JDBC URL. The syntax of the JDBC URL is jdbc:mongodb: followed by the connection properties in a semicolon-separated list of name-value pairs.

    A typical connection string is below:

    jdbc:mongodb:Server=127.0.0.1;Port=27017;Database=test;User=test;Password=test;

  6. Click Connect.
  7. If the connection succeeds, set the Database Type to Generic.

Discover Schemas and Query MongoDB Data

You can now browse data and execute SQL in the following ways:

  • To access the available tables, from the Databases tab, expand the nodes for the connection, database, schema, and table or view.
  • To browse through table data and metadata, right-click a table and click Open in Tab or Open in New Tab.
  • To execute SQL queries, select SQL Commander > New SQL Commander. Select the Database Connection, Database, and Schema from the available menus.

See NoSQL Database for information on querying specific tables. See SQL Compliance for more information on the SQL syntax.

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060