mongodb-as-a-datasource demonstrates using the mongodb Translator to access data in mongodb.
To start the server, open a command line and navigate to the "bin" directory under the root directory of the Teiid server and run:
./standalone.sh //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}
./standalone.sh -c standalone-teiid.xml
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" }
run the following CLI script
cd $JBOSS_HOME/bin ./jboss-cli.sh --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.
Copy the following files to the "/standalone/deployments" directory
src/vdb/mongodb-vdb.xml src/vdb/mongodb-vdb.xml.dodeploy
Open the admin console(http://localhost:9990/console) to make sure the VDB is deployed. See Query Demonstrations below to demonstrate query.
-
Change your working directory to "${quickstart.install.dir}/simpleclient"
-
Use the simpleclient example to run the following queries:
Example: mvn exec:java -Dvdb="mongoVDB" -Dsql="select * from Employee"
Note
|
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. |