neo4j-driver-java-skill

Implement Neo4j Java Driver v6 connectivity, transactions, and query execution.

101|35|Updated Jan 20, 2026
One-click install
npx skills add https://github.com/neo4j-contrib/neo4j-skills --skill neo4j-driver-java-skill
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: neo4j-driver-java-skill
Source: https://github.com/neo4j-contrib/neo4j-skills/tree/main/neo4j-driver-java-skill
Command: npx skills add https://github.com/neo4j-contrib/neo4j-skills --skill neo4j-driver-java-skill

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Neo4j application developers struggle to implement correct, production-safe connection and transaction handling with the official Java Driver, leading to subtle bugs like leaked sessions, invalid result lifecycles, and unreliable error recovery.

Core Features & Use Cases

  • Dependency setup (Maven/Gradle): add the official neo4j-java-driver v6 artifact with the right version.
  • Driver lifecycle best practices: create a long-lived Driver, call verifyConnectivity, and close it correctly.
  • Correct querying APIs and transaction models: use executableQuery as the recommended default and use executeRead/executeWrite managed transactions safely (including result consumption inside callbacks).
  • Async and reactive access: use CompletableFuture/CompletionStage patterns and Reactor/Rx reactive sessions for non-blocking execution.
  • Robust error handling and retry awareness: handle ServiceUnavailableException, transient failures, Neo4jException, and design around commit uncertainty for explicit transactions.
  • Type mapping and null-safety: safely extract values with the correct accessors, avoid pitfalls with graph nulls and absent keys, and map results to Java records.

Use case example: Build a Java service that reads customer nodes and writes updates reliably by enforcing managed transaction rules, consuming results inside callbacks, batching writes with UNWIND, and handling transient failures without corrupting transaction state.

Quick Start

Ask the skill to generate a minimal Java example that creates a Neo4j Driver, runs a parameterized read using executableQuery, and safely consumes records.

Frequently Asked Questions about neo4j-driver-java-skill

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle Neo4j transactions correctly in a Java service?

Use the Neo4j Java Driver's managed transaction functions like executeRead and executeWrite to handle transaction boundaries safely. This ensures results are consumed inside callbacks and prevents invalid result lifecycles or leaked sessions.

What is the best way to run reactive queries with the Neo4j Java Driver?

The Neo4j Java Driver supports reactive workflows using Reactor and Rx patterns. You can use reactive sessions for non-blocking query execution while maintaining robust error handling and connection pool tuning.

How do I manage the driver lifecycle when connecting to Neo4j from Java?

Create a long-lived Neo4j Driver instance, call verifyConnectivity to ensure availability, and close it correctly during application shutdown. This pattern prevents connection leaks and maintains causal consistency with bookmarks.

How do I handle transient failures and ServiceUnavailableException in the Neo4j Java Driver?

Handle transient failures and ServiceUnavailableException by leveraging the Neo4j Java Driver's built-in retry logic for managed transactions. For explicit transactions, design around commit uncertainty to avoid corrupting transaction state.

How do I safely extract values and map results to Java records with the Neo4j Java Driver?

Use the Neo4j Java Driver's type mapping with correct accessors to safely extract values and map results to Java records. This approach avoids pitfalls with graph nulls and absent keys by enforcing null safety.

Can I batch writes with UNWIND using the Neo4j Java Driver's executableQuery?

Yes, the Neo4j Java Driver supports batching writes with UNWIND through the executableQuery default API. This method allows parameterized queries while adhering to batching constraints for reliable bulk updates.