Configure Neo4j Connection

To connect to the Neo4j database, you will need to set a few configuration properties.

Complete the following steps:

  1. In the src/main/resources folder, open the application.properties file and set the properties to your database credentials, matching the values below.

env
application.properties File
NEO4J_URI=[copy]#neo4j://{sandbox-ip}:{sandbox-boltPort}#
NEO4J_USERNAME=[copy]#{sandbox-username}#
NEO4J_PASSWORD=[copy]#{sandbox-password}#

Each of the above properties are as follows:

  1. NEO4J_URI - the connection URI string for our database. For example, neo4j://localhost:7687 or neo4j+s://<dbhash>.databases.neo4j.io.

  2. NEO4J_USERNAME and NEO4J_PASSWORD - properties to authenticate with the database.

Applying Application Properties

Remember to restart the process after saving the application.properties file to apply the application properties.

Once saved, these can be accessed through the application.properties variable.

java
Accessing Application Properties
var properties = AppUtils.loadProperties();
var uri = System.getProperty("NEO4J_URI");

Authentication Types

Neo4j supports four authentication methods, basic authentication (e.g. username and password or LDAP), a base64 encoded Bearer token, a Kerberos token, or a custom authentication token. For more information on these options, visit Authentication and Authorization.

Lesson Summary

In this lesson, you added connection details to your application and tested the connection to the Neo4j database. This lesson completes Module 1 of the course.

In the next module, you will learn about mapping the graph data model to the application domain model.