Skip to content

carlostse/mongo-jdbc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mongo JDBC Driver

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.

Scenario

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.

Project Scope

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

Quick Start

  1. Import the pom.xml in IntelliJ IDEA
  2. Right click examples and select Mark Directory as, Sources Root
  3. Right click HelloWorld and select Run HelloWorld.main()

Platform

Java

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.

Build JDBC JAR

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

License

Apache License, Version 2.0

About

JDBC Driver for MongoDB

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%