JDBC driver for MongoDB. A wrapper translates SQL to official MongoDB Java API calls.
This is a fork of http://github.com/erh/mongo-jdbc, and merged some changes from:
EXPERIMENTAL
This project targets to support some simple SQL only, and has no plans to support join tables.
A traditional JDBC application needs to read data stored in MongoDB. Instead of maintaining two copies of data, a JDBC driver has been made. The JDBC application can use the traditional SQL to access the MongoDB without modifications.
JDBC Connection
- support connection to a ReplicaSet
- support connection to a Sharded Cluster
Query Types
- support SELECT on single table
- support WHERE
- support ORDER BY and LIMIT
- upgrade Java MongoDB Driver to latest version (3.4.1)
- support MongoDB replica set
- replace deprecated Java MongoDB Driver APIs
- update test cases
- Import the
pom.xml
in IntelliJ IDEA - Right click examples and select Mark Directory as, Sources Root
- Right click
HelloWorld
and select Run HelloWorld.main()
This project targets to support Java 8. Some additional JDBC functions were added since Java 7, thus which may cause errors where compiling using Java 6 or below, and it is not supported in this project.
If you have MongoDB running on localhost
$ mvn package
If you have MongoDB running on remote machine
$ mvn package -Dmongodb=<MongoDB Hostname or IP address(:port)>
If you do have any MongoDB or want to skip the tests
$ mvn package -Dmaven.test.skip=true
You need to add the following dependency JARs in classpath
mongo-java-driver-<version>.jar
jsqlparser-<version>.jar
Or, you can package all dependencies in one single JAR file
$ mvn assembly:single
Apache License, Version 2.0