Connecting to MongoDB database
ODBC Connector now supports MongoDB database
ODBC Connector has been certified with limited support to connect to MongoDB Database. In order to avail this connectivity, you must have the latest DataDirect ODBC Driver set installed which includes the MongoDB ODBC Driver (VMmongo00.so or VMmongo00.dll).
As MongoDB is a NoSQL database, you must define or correctly map the fields with the correct data type so that ODBC Connector can operate on those fields with the metadata specified. In order to automate this process, DataDirect has come up with a tool called schematool, which samples the collections in the MongoDB database and maps the fields to the most reasonable data type. The sampling would need at least 1000 records in the collection so that the driver can correctly guess the field to its correct data type.
Starting with version 8.1 of the MongoDB ODBC Driver, the schematool was removed, and the schemamap files are created at the first connection to the MongoDB database.
Configuring the ODBC DSN for MongoDB database
[MongoDBDSN]
Driver=/opt/IBM/InformationServer/Server/branded_odbc/lib/VMmongo00.so
Description=DataDirect MongoDB ODBC Driver Wire Protocol
DatabaseName=<database-name>
User=
Password=
HostName=<Server-IP>
PortNumber=<Port-Number>
SchemaMap =</tmp/mongo/mongodbtest.config>
CreateMap=2
ReadOnly=0
TransactionMode=1
ServerPortNumber=19967
SQLEngineMode=0
The text in bold must be replaced with the actual values according to your environment.
On Windows platform, once the DataDirect ODBC Driver set with MongoDB ODBC Driver is installed, Windows ODBC Administrator tool should be used to create the MongoDB ODBC DSN with appropriate settings similar to the ones specified above for the UNIX platform.
Starting the SQLEngine
- For 8.0 version of the driver:
-
/opt/IBM/InformationServer/jdk/jre/bin/java -Xmx1024m -cp /opt/IBM/InformationServer/Server/branded_odbc/java/lib/mongodb.jar com.ddtek.mongodbcloud.sql.Server -port 19967
- For 8.1 version of the driver:
-
/opt/IBM/InformationServer/jdk/jre/bin/java -Xmx1024m -cp /opt/IBM/InformationServer/Server/branded_odbc/java/lib/mongodb.jar com.ddtek.jdbc.mongodb.phoenix.sql.Server -port 19967
- For the 32-bit driver, the default is 19968
- For the 64-bit driver, the default is 19967
For more details on the schematool, SQLEngine, connection parameters, data types that are currently supported , see MongoDB ODBC Driver user guide.
Creating a schema map (applicable only to the 8.0 version of the driver)
java -jar
$DSHOME/../branded_odbc/tools/schematool.jar
On Windows platform, the schematool can be started by clicking schematool button through Windows ODBC Administrator tool. The schematool facilitates the user to modify the sampled collections for the correct field types. Once the schemamap is saved, you must specify the same path name in the ODBC DSN configuration on UNIX platforms. On the Windows platform, the route is picked by default; however, the user can change it to the appropriate path. When extra collections are introduced after a schema map is formed, you must restart the schematool GUI, which will then prompt for the new native objects discovered following the previous mapping. You can also update the schema map or ignore the new collections. Later, the ignored collections can be added by clicking the "+" symbol in the schematool GUI window. Once the schema definition is successfully constructed, you can design jobs that connect to MongoDB and run them, and also import metadata by using the ODBC Connector.
The MongoDB version 8.1 driver generates a compressed schema map file, which reduces disk space and improves speed. As a result, if possible, it is suggested that the schemamap files be regenerated using the 8.1 version. However, there may be changes in how the tables are constructed. By default, when upgrading to the 8.1 version of the driver, the driver attempts to migrate the schemamap files that are generated by the 8.0 version to the 8.1 version. If there are issues, they are reported.
If a user wants to force the creation of schemamap files by using the most recent version of the MongoDB ODBC Driver, they can set the following connection parameter once and establish a connection. The first connection attempt generates the schemamap files by using the newer version of the driver. But, the previous schemamap files that are generated by the driver version 8.0 will be ignored.
CreateMap=ForceNew
- Once the schemamap files are successfully created, this connection parameter can be set to
CreateMap=NotExist
. For more details on this connection parameter, see MongoDB ODBC Driver.
- What's new in this release?
- MongoDB ODBC Driver Documentation
- Migrating schema maps and native files to 8.1
- Backward compatibility notes while migrating from MongoDB JDBC/ODBC Driver 6.0/8.0 to 6.1/8.1 version
- Does the 8.1 MongoDB driver provide backward compatible support for the 8.0 MongoDB property names?
- Connection option descriptions
If there are issues after upgrading the schemamap files to the 8.1 version and you want to revert to using the 8.0 version of the driver, see Steps to follow to revert back the schema map files from 8.1 to 8.0 for the cases where the 8.1 map migration or subsequent loading of the migrated map results in an error.
- Complex data types aren't supported
- For nested collections, you must either flatten the schema or normalize the schema by using the schematool GUI utility and use proper queries (applicable only to 8.0 version)
- Create and Replace Write modes are not supported
- Insert with primary key violation, Insert News Only and Insert then Update write modes doesn't work as expected (database limitation)
- Views are not supported by the 8.0 version of the driver