Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
83 lines (55 sloc) 2.95 KB

What is it?

mongodb-as-a-datasource demonstrates using the mongodb Translator to access data in mongodb.

System requirements

Setup and Deployment

1. Start the server

To start the server, open a command line and navigate to the "bin" directory under the root directory of the Teiid server and run:

./ //For Linux
standalone.bat //for Windows

If Teiid isn’t configured in the default configuration, append the following arguments to the command to specify the configuration -c {configuration.file}

./ -c standalone-teiid.xml

2. Setup mongoDB

For install, admin and getting start with mongoDB refer to mongoDB manual. In this quickstart, we assume the employee document be insert under Employee connection as below:

db.Employee.insert({employee_id: '1', FirstName: 'Test1', LastName: 'Test1'});
db.Employee.insert({employee_id: '2', FirstName: 'Test2', LastName: 'Test2'});
db.Employee.insert({employee_id: '3', FirstName: 'Test3', LastName: 'Test3'});

Also the query document commands output as below:

> db.Employee.find();
{ "_id" : ObjectId("545c51d0ff38114a62627a73"), "employee_id" : "1", "FirstName" : "Test1", "LastName" : "Test1" }
{ "_id" : ObjectId("545c51e1ff38114a62627a74"), "employee_id" : "2", "FirstName" : "Test2", "LastName" : "Test2" }
{ "_id" : ObjectId("545c51efff38114a62627a75"), "employee_id" : "3", "FirstName" : "Test3", "LastName" : "Test3" }

3. Install the mongoDB datasource to be referenced by the Teiid VDB

run the following CLI script

cd $JBOSS_HOME/bin
./ --connect --file={path}/mongodb-as-a-datasource/src/scripts/setup.cli

NOTE - Before executing setup.cli, either modify setup.cli change ${mongodb.serverlist} to mongoDB server list and {mongodb.dbname} to mongoDB DB name, or set System Properties mongodb.serverlist point to mongoDB server list and mongodb.dbname to mongoDB DB name.

4. VDB Deployment

Copy the following files to the "/standalone/deployments" directory


Open the admin console(http://localhost:9990/console) to make sure the VDB is deployed. See Query Demonstrations below to demonstrate query.

Query Demonstrations

  1. Change your working directory to "${quickstart.install.dir}/simpleclient"

  2. Use the simpleclient example to run the following queries:

Example: mvn exec:java -Dvdb="mongoVDB" -Dsql="select * from Employee"

depending on your OS/Shell the quoting/escaping required to run the example can be complicated. It would be better to install a Java client, such as SQuirreL, to run the queries.