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 in the AWS SDK for Java Developer Guide.


    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 in the IAM User Guide.

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

    • US East (N. Virginia):   us-east-1

    • US East (Ohio):   us-east-2

    • US West (Oregon):   us-west-2

    • EU (Ireland):   eu-west-1

    • EU (London):   eu-west-2

    • EU (Frankfurt):   eu-central-1

    • Asia Pacific (Singapore):   ap-southeast-1

    • Asia Pacific (Sydney):   ap-southeast-2

    • Asia Pacific (Tokyo):   ap-northeast-1

    • Asia Pacific (Mumbai):   ap-south-1

    • Asia Pacific (Seoul):   ap-northeast-2

    • EU (Stockholm):   eu-north-1

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. Get the latest version of the project by checking out the branch with the latest tag.

    git checkout $(git describe --tags `git rev-list --tags --max-count=1`)
  4. 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"
  5. 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.