Skip to content

Memgraph JDBC driver for Bolt protocol (database agnostic)

License

Notifications You must be signed in to change notification settings

memgraph/bolt-jdbc-driver

 
 

Repository files navigation

Overview: Bolt Protocol JDBC Driver

This is a JDBC driver for Bolt protocol supporting Cypher over JDBC, forked by Memgraph to support all graph databases with Bolt protocol.

This driver was mainly developed by Larus BA, Italy, a certified consulting and integration solutions partner for Neo4j. Thank you so much for all your work.

Thanks to this driver it’s possible for projects that are using the classic JDBC connector in the relational paradigm to interact with graph databases, who didn’t have a way to be queried in a relational way up until now.

Maven dependency

For making the Bolt JDBC Driver a dependency, you can simply use:

<dependency>
    <groupId>org.memgraph</groupId>
    <artifactId>bolt-jdbc-driver</artifactId>
    <version>{bolt-jdbc-version}</version>
    <scope>runtime</scope>
</dependency>

Minimum viable snippet

The snippet was run using Memgraph

Run Query
// Connecting
try (Connection connection = DriverManager.getConnection("jdbc:graph:bolt://localhost", "user", password);
    // Querying
     PreparedStatement stmt = connection.prepareStatement("MATCH (u:User)-[:FRIEND]-(f:User) WHERE u.name = $0 RETURN f.name, f.age")) {

    stmt.setString(0, "John");

    try (ResultSet rs = stmt.executeQuery()) {
        while (rs.next()) {
            System.out.println("Friend: "+rs.getString("f.name")+" is "+rs.getInt("f.age"));
        }
    }
}

Please note that the example above uses the try-with-resource blocks that automatically closes resources when the try block is exited.

Flattening

As most JDBC clients and tools don’t support complex objects, the driver can flatten returned nodes and relationships by providing all their properties as individual columns with names like u.name,r.since if you just return a node u or relationship r.

This is enabled with the JDBC-URL parameter flatten=<rows>, where <rows> indicates how many rows are sampled to determine those columns. With -1 all rows are sampled and with any other value you determine the number of rows being looked at.

Building the driver yourself

First clone the repository.

Run all unit tests & integration tests
mvn clean test
Run only integration tests
mvn clean test -Pintegration-test
Run performance tests
mvn clean test -Pperformance-test

License

Copyright (c) Neo4j and LARUS Business Automation

The "Bolt JDBC Driver" is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.

You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.

About

Memgraph JDBC driver for Bolt protocol (database agnostic)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%