• Stars
    star
    329
  • Rank 128,030 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Neo4j Bolt driver for Java

Neo4j Java Driver

This repository holds the official Java Driver for Neo4j.

It works with both single instance and clustered databases.

Network communication is handled using Bolt Protocol.

Versioning

Starting with 5.0, the Neo4j Drivers will be moving to a monthly release cadence. A minor version will be released on the last Friday of each month so as to maintain versioning consistency with the core product (Neo4j DBMS) which has also moved to a monthly cadence.

As a policy, patch versions will not be released except on rare occasions. Bug fixes and updates will go into the latest minor version and users should upgrade to that. Driver upgrades within a major version will never contain breaking API changes.

Supported Driver Series

Driver Series Supported Java Runtime versions Status Changelog
5.x 17 Primary development branch. link
4.4 8, 11 Maintenance. link

Server Compatibility

The compatibility with Neo4j Server versions is documented in the Neo4j Knowledge Base.

Preview features

The preview feature is a new feature that is a candidate for a future GA status.

It enables users to try the feature out and maintainers to refine and update it.

The preview features are not considered to be experimental, temporary or unstable.

However, they may change more rapidly, without following the usual deprecation cycle.

Most preview features are expected to be granted the GA status unless some unexpected conditions arise.

Due to the increased flexibility of the preview status, user feedback is encouraged so that it can be considered before the GA status.

Every feature gets a dedicated GitHub Discussion where feedback may be shared.

Usage

This section provides general information for engineers who are building Neo4j-backed applications.

The pom.xml file

The driver is distributed exclusively via Maven. To use the driver in your Maven project, include the following within your pom.xml file:

<dependency>
    <groupId>org.neo4j.driver</groupId>
    <artifactId>neo4j-java-driver</artifactId>
    <version>x.y.z</version>
</dependency>

Here, x.y.z will need to be replaced with the appropriate driver version. It is generally recommended to use the latest driver version wherever possible. This ensures access to new features and recent bug fixes. All available versions of this driver can be found at Maven Central or Releases.

Java Platform Module System

Both neo4j-java-driver and neo4j-java-driver-all artifacts have org.neo4j.driver module name.

Starting from version 5.0 the neo4j-java-driver includes an explicit module declaration (module-info.java).

The neo4j-java-driver-all includes an explicit module declaration (module-info.java) starting from version 5.7.

Example

To run a simple query, the following can be used:

var authToken = AuthTokens.basic("neo4j", "password");
try (var driver = GraphDatabase.driver("bolt://localhost:7687", authToken)) {
    var result = driver.executableQuery("CREATE (n)").execute();
    System.out.println(result.summary().counters().nodesCreated());
}

For full applications, a single Driver object should be created with application-wide scope and lifetime. This allows full utilization of the driver connection pool. The connection pool reduces network overhead added by sharing TCP connections between subsequent transactions. Network connections are acquired on demand from the pool when running Cypher queries, and returned back to connection pool after query execution finishes. As a result of this design, it is expensive to create and close a Driver object. Session objects, on the other hand, are very cheap to use.

Thread Safety

Driver objects are thread-safe, but Session and Transaction objects should only be used by a single thread.

Further reading

Check out our Wiki for detailed and most up-to-date manuals, driver API documentations, changelogs, etc.

Bug Report

If you encounter any bugs while using this driver, please follow the instructions in our Contribution Guide when raising an issue at Issues.

When reporting, please mention the versions of the driver and server, as well as the server topology (single instance, causal cluster, etc). Also include any error stacktraces and a code snippet to reproduce the error if possible, as well as anything else that you think might be helpful.

For Driver Engineers

This section targets users who would like to compile the driver source code on their own machine for the purpose of, for example, contributing a PR. Before contributing to this project, please take a few minutes to read our Contribution Guide.

Java Version

For the 1.5+ Driver Series, the source code must compile on Java 8.

For the previous versions, the compilation requires Java 7.

Building

The source code here reflects the current development status of a new driver version.

To use the driver in a project, please use the released driver via Maven Central or check out the code with git tags of corresponding versions instead.

Running Tests and Creating a Package

The following command may be used to unit test and install artifacts without running integration tests:

mvn clean install -DskipITs -P skip-testkit

Integration tests have the following prerequisites:

Testkit that is a tooling that is used to run integration tests for all official Neo4j drivers. It can be executed using Docker during Maven build and in such case does not require additional setup. See the instructions below for more details.

There are 2 ways of running Testkit tests:

  1. Using the testkit-tests module of this project.
  2. Manually cloning Testkit and running it directly.
Using the testkit-tests module

The testkit-tests module will automatically check out Testkit and run it during Maven build.

Prerequisites:

  • Docker
  • /var/run/docker.sock available to be passed through to running containers. This is required because Testkit needs access to Docker in order to launch additional containers.
  • The driver project location must be sharable with Docker containers as Testkit container needs to have access to it.

Make sure to run build for the whole project and not just for testkit-tests module. Sample commands:

  • mvn clean verify - runs all tests.
  • mvn clean verify -DskipTests - skips all tests.
  • mvn clean verify -DtestkitArgs='--tests STUB_TESTS' - runs all project tests and Testkit stub tests.
  • mvn clean verify -DskipTests -P testkit-tests - skips all project tests and runs Testkit tests.
  • mvn clean verify -DskipTests -DtestkitArgs='--tests STUB_TESTS' - skips all project tests and runs Testkit stub tests.
  • mvn clean verify -DskipITs -DtestkitArgs='--tests STUB_TESTS' - skips all integration tests and runs Testkit stub tests.
  • mvn clean verify -DskipTests -DtestkitArgs='--run-only-selected tests.neo4j.test_session_run.TestSessionRun.test_can_return_path --configs 4.4-enterprise-neo4j' - skips all project tests and runs selected Testkit test on specific configuration.

If you interrupt Maven build, you have to remove Testkit containers manually.

Running Testkit manually

Prerequisites:

  • Docker
  • Python3
  • Git

Clone Testkit and run as follows:

git clone [email protected]:neo4j/neo4j-java-driver.git 
git clone [email protected]:neo4j-drivers/testkit.git
cd testkit
TEST_DRIVER_NAME=java \
TEST_DRIVER_REPO=`realpath ../neo4j-java-driver` \
TEST_DOCKER_RMI=true \
python3 main.py --tests UNIT_TESTS --configs 4.3-enterprise

To run additional Testkit test, specify TESTKIT_TESTS:

TEST_DRIVER_NAME=java \
TEST_DRIVER_REPO=`realpath ../neo4j-java-driver` \
TEST_DOCKER_RMI=true \
python3 main.py --tests TESTKIT_TESTS UNIT_TESTS --configs 4.3-enterprise

On Windows or in the absence of a Bash-compatible environment, the required steps are probably different. A simple mvn clean install will require admin rights on Windows, because our integration tests require admin privileges to install and start a service.

If all of this fails and you only want to try out a local development version of the driver, you could skip all tests like this:

mvn clean install -DskipTests

More Repositories

1

neo4j

Graphs for Everyone
Java
13,266
star
2

NaLLM

Repository for the NaLLM project
TypeScript
1,253
star
3

neo4j-python-driver

Neo4j Bolt driver for Python
Python
898
star
4

neo4j-javascript-driver

Neo4j Bolt driver for JavaScript
JavaScript
853
star
5

neo4j-browser

Neo4j Browser is the general purpose user interface for working with Neo4j. Query, visualize, administrate and monitor the database.
TypeScript
690
star
6

graph-data-science

Source code for the Neo4j Graph Data Science library of graph algorithms.
Java
629
star
7

graphql

A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations.
TypeScript
504
star
8

neo4j-go-driver

Neo4j Bolt Driver for Go
Go
494
star
9

docker-neo4j

Docker Images for the Neo4j Graph Database
Shell
333
star
10

neo4j-ogm

Java Object-Graph Mapping Library for Neo4j
Java
332
star
11

neo4j-spark-connector

Neo4j Connector for Apache Spark, which provides bi-directional read/write access to Neo4j from Spark, using the Spark DataSource APIs
Scala
313
star
12

neo4j-dotnet-driver

Neo4j Bolt driver for .NET
C#
231
star
13

cypher-dsl

A Java DSL (Builder) for the Cypher Query Language
Java
194
star
14

graph-data-science-client

A Python client for the Neo4j Graph Data Science (GDS) library
Python
191
star
15

neo4j-graphrag-python

Neo4j GraphRAG for Python
Python
172
star
16

neo4j-jdbc

Official Neo4j JDBC Driver
Java
135
star
17

neo4j-documentation

Scala
103
star
18

apoc

Java
94
star
19

cypher-shell

Cypher Shell has moved to https://github.com/neo4j/neo4j
Java
89
star
20

trillion-graph

A scale demo of Neo4j Fabric spanning up to 1129 machines/shards running a 100TB (LDBC) dataset with 1.2tn nodes and relationships.
Java
89
star
21

docker-neo4j-publish

Shell
83
star
22

sdn-rx

Nextgen Spring Data module for Neo4j supporting (not only) reactive data access and immutable support
Java
65
star
23

helm-charts

Go
59
star
24

cypher-builder

A library for building Cypher queries for Neo4j programmatically.
TypeScript
50
star
25

cypher-editor

Codemirror editor for Cypher, with syntax awareness and auto-completion
JavaScript
42
star
26

neo4j-java-driver-spring-boot-starter

Automatic configuration of Neo4j's Java Driver for Spring Boot applications
Java
33
star
27

cypher-language-support

Neo4j's Cypher Language support
TypeScript
31
star
28

neo4j-example-auth-plugins

Example authentication and authorization plugins for Neo4j
Java
17
star
29

neo4j-ogm-quarkus

Quarkus extension to that allows proper usage of Neo4j-OGM inside Quarkus.
Java
13
star
30

neo4j-python-driver-rust-ext

Optional Rust Extensions to Speed Up the Python Driver
Python
13
star
31

graphql-tracker-temp

This is a temporary repository for documentation and tracking issues for the @neo4j/graphql package until that repo is made public
12
star
32

docs-cypher

Neo4j Cypher Documentation
JavaScript
12
star
33

graph-schema-introspector

This is a Proof of concept (PoC) for a Neo4j schema introspector that produces output in JSON format validating against graph-schema-json-js-utils.
Java
11
star
34

docs-drivers

Neo4j Drivers Documentation
Python
10
star
35

windows-wrapper

A service wrapper for windows
Java
9
star
36

docs-bolt

Neo4j Bolt Protocol Documentation
JavaScript
7
star
37

neo4j.github.com

Web published resources
HTML
7
star
38

dappr

Distributed Approximate Personalised PageRank
Jupyter Notebook
6
star
39

docs-operations

Neo4j Operations documentation
JavaScript
6
star
40

docs-getting-started

JavaScript
6
star
41

jsr311-api

Forked from revision 612
Java
6
star
42

docs-graphql

GraphQL docs
JavaScript
5
star
43

doctools

Perl
5
star
44

graph-schema-json-js-utils

Utility library to work with the Graph Schema JSON representation
TypeScript
5
star
45

docs-aura

Jupyter Notebook
5
star
46

kafka-connector-workshop

TypeScript
4
star
47

neo4j-kafka-connector

Neo4j Kafka Connector
Kotlin
4
star
48

graphql-toolbox

TypeScript
4
star
49

github-action-traceability

TypeScript
4
star
50

docs-status-codes

Documentation for Neo4j status codes
JavaScript
4
star
51

parents

Neo4j Build Configuration
4
star
52

neo4j-aws-terraform

HCL
3
star
53

docs-http-api

Documentation for Neo4j HTTP API
JavaScript
3
star
54

jbang-catalog

JBang catalog
Java
2
star
55

import-spec

Java
2
star
56

docs-maven-plugin

Java
2
star
57

ease-maven-plugin

Java
2
star
58

license-maven-plugin

Fork of http://code.google.com/p/maven-license-plugin/
Java
2
star
59

maven-skin

Neo4j Maven Skin
Java
2
star
60

docs-bloom

JavaScript
1
star
61

docs-data-importer

JavaScript
1
star
62

azure-neo4j

Azure topology files
Shell
1
star
63

clirr-maven-plugin

Java
1
star
64

neo4jtester

neo4j tester
Go
1
star
65

docs-genai-tutorials

Python
1
star
66

docs-ops-manager

JavaScript
1
star