Amazon Neptune
User Guide (API Version 2017-11-29)

Connecting to Neptune Using Java and SPARQL with Signature Version 4 Signing (RDF4J and Jena)

This section shows how to connect to Neptune using either RDF4J or Apache Jena with Signature Version 4 authentication.


  • Java 8 or higher.

  • Apache Maven 3.3 or higher.

    For information about installing these prerequisites on an EC2 instance running Amazon Linux, see Prerequisites on Amazon Linux EC2.

  • IAM credentials to sign the requests. For more information, see Using the Default Credential Provider Chain.


    If you are using temporary credentials, they expire after a specified interval, including the session token.

    You must update your session token when you request new credentials. For more information, see Using Temporary Security Credentials to Request Access to AWS Resources.

  • Set the SERVICE_REGION variable to one of the following, indicating the Region of your Neptune DB instance:

    • us-east-1

    • us-east-2

    • us-west-2

    • eu-west-1

    • eu-west-2

    • eu-central-1

    • ap-southeast-1

    • ap-southeast-2

    • ap-northeast-1

    • ap-south-1

    • ap-northeast-2

To connect to Neptune using either RDF4J or Apache Jena with Signature Version 4 signing

  1. Clone the sample repository from GitHub.

    git clone
  2. Change into the cloned directory.

    cd amazon-neptune-sparql-java-sigv4
  3. Enter one of the following commands to compile and run the example code.

    Replace your-neptune-endpoint with the hostname or IP address of your Neptune DB instance. The default port is 8182.


    For information about finding the hostname of your Neptune DB instance, see the Connecting to Amazon Neptune Endpoints section.

    Eclipse RDF4J

    Enter the following to run the RDF4J example.

    mvn compile exec:java \ -Dexec.mainClass="com.amazonaws.neptune.client.rdf4j.NeptuneRdf4JSigV4Example" \ -Dexec.args="https://your-neptune-endpoint:port"

    Apache Jena

    Enter the following to run the Apache Jena example.

    mvn compile exec:java \ -Dexec.mainClass="com.amazonaws.neptune.client.jena.NeptuneJenaSigV4Example" \ -Dexec.args="https://your-neptune-endpoint:port"
  4. To view the source code for the example, see the examples in the src/main/java/com/amazonaws/neptune/client/ directory.

To use the SigV4 signing driver in your own Java application, add the amazon-neptune-sigv4-signer Maven package to the <dependencies> section of your pom.xml. We recommend that you use the examples as a starting point.