This is the official JDBC driver for Neo4j.
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.
Note
|
The previous JDBC driver for Neo4j 2.x was moved to the https://github.com/neo4j-contrib/neo4j-jdbc-2x repository. |
Being a graph database, Neo4j is not serving data in a relational way and the exact purpose of this project is to allow projects that are using the classic JDBC connector in the relational paradigm to interact with Neo4j.
This driver supports various types of database transports:
-
through the BOLT protocol (3.0.X) using
jdbc:neo4j:bolt://<host>:<port>/
-
through the HTTP protocol (2.X+) using
jdbc:neo4j:http://<host>:<port>/
Going forward there will also be support for:
-
direct file connection
-
embedded connection
org.neo4j:neo4j-jdbc:3.0
// Connect
Connection con = DriverManager.getConnection("jdbc:neo4j:bolt://localhost");
// Querying
String query = "MATCH (u:User)-[:FRIEND]-(f:User) WHERE u.name = {1} RETURN f.name, f.age";
try (PreparedStatement stmt = con.prepareStatement(query)) {
stmt.setString(1,"John");
ResultSet rs = con.execute();
while (rs.next()) {
System.out.println("Friend: "+rs.getString("f.name")+" is "+rs.getInt("f.age"));
}
}
con.close();
-
Install a Neo4j 3.0.X server and start it with the BOLT protocol enabled
-
Connect with URLs in the form
jdbc:neo4j:bolt://<host>:<port>/
(e.g.jdbc:neo4j:bolt://localhost/
) -
You can also use additional comma separated parameters in the URL for authentication, debug mode, ssl encryption and flattening e.g.
jdbc:neo4j:bolt://localhost/?user=neo4j,password=xxxx,debug=true,noSsl,flatten=[-1,100,1000]
-
Add the JDBC driver dependency or jar file to your project
-
Get a connection from DriverManager
-
Execute queries and transactions using the Cypher graph query language
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.
First clone the repository.
This project is composed by the following modules:
-
Neo4j JDBC - the core module
-
Neo4j JDBC - Bolt - module supporting the bolt protocol
-
Neo4j JDBC - Http - module supporting the http protocol
-
Neo4j JDBC - Driver packaging - module to package all above modules
mvn clean test
mvn clean test -Pintegration-test
mvn clean test -Pperformance-test
Note
|
To run the performance test, you must have a Neo4j Server (3.0.X) running with the Bolt protocol enabled on port 7687 (default) |
General Availability [RELEASED]
-
Extensive Tests with a variety of tools
-
Bug Fixes
-
Documentation
-
Better handling of credentials
-
Support for additional API methods
-
Explicit enabling of
flatten=<rows>
via jdbc URL
Release Candidate 1 [RELEASED]
-
Move to github.com/neo4j-contrib
-
Changed package to
org.neo4j
-
Released to Neo4j’s maven repository
-
HTTP protocol module
Milestone 03 [RELEASED]
-
Batch processing
-
Bug fix
-
Neo4j Java Driver 1.0.1
-
Neo4j 3.0.1
Copyright (c) 2016 Neo4j and LARUS Business Automation
The "Neo4j 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.
We’d like to thank:
The core development team:
-
Alberto D’Este, Larus-BA - Software Developer
-
Marco Falcier, Larus-BA - Software Developer
-
Gianmarco Laggia, Larus-BA - Software Developer
-
Benoît Simard, Neo4j - Technical Consultant at Neo Technology
Contributors:
-
Ralf Becher, TiQ solutions - Qlik Luminary
-
Michael Vitz, InnoQ - Software Developer
-
Angelo Busato, Larus-BA - Software Developer
-
Enrico Marin, Larus-BA - Software Developer
Supporters:
-
Lorenzo Speranzoni, Larus-BA - Founder and CEO
-
Stefan Armbruster, Neo4j - Customer Success Engineer for EMEA
-
Michael Hunger, Neo4j - Caretaker Neo4j Community