Skip to content


Repository files navigation

Oracle NoSQL Database SDK for Spring Data


Oracle NoSQL SDK for Spring Data provides a Spring Data implementation module to connect to an Oracle NoSQL Database cluster or to Oracle NoSQL Cloud Service.


Java versions 17 and higher are supported.


The Oracle NoSQL SDK for Spring Data can be included in a project in 2 ways:

  1. Include a dependency in a Maven project
  2. Download from GitHub

Install as a Project Dependency

This dependency can be used to include the SDK and its dependencies in your project. The version changes with each release.


Optionally, the packages can be manually installed in a local maven repository by downloading from releases page, and running the following command (-sources and -javadoc files are optional):

mvn install:install-file \
-DpomFile=spring-data-oracle-nosql-x.y.z.pom \
-Dfile=spring-data-oracle-nosql-x.y.z.jar \
-Dsources=spring-data-oracle-nosql-x.y.z-sources.jar \

Download from GitHub

You can download the Oracle NoSQL SDK for Spring Data as an archive from GitHub. The archive contains the runtime library and its dependencies, examples, and API documentation.


See Oracle NoSQL SDK for Spring Data javadoc for the latest API documentation. See Spring Data SDK Developers Guide for examples and additional details on the SDK.

General documentation about the Oracle NoSQL Database Cloud Service, Oracle NoSQL Database and Spring Data SDK Developers Guide can be found in these locations:


See CHANGELOG for changes in each release.


  • The example below also requires an additional dependency:

  • Define an AppConfig class that provides a nosqlDBConfig bean that returns an Oracle NoSQL DB configuration:

    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import oracle.nosql.driver.kv.StoreAccessTokenProvider;
    public class AppConfig extends AbstractNosqlConfiguration {
        public NosqlDbConfig nosqlDbConfig() {
            return new NosqlDbConfig(
                "localhost:8080",                   // endpoint URL
                new StoreAccessTokenProvider());    // AuthorizationProvider

Note: Depending on individual scenario use the appropriate AuthorizationProvider:

  • For cloud configuration use the following example or see documentation:

    new oracle.nosql.driver.iam.SignatureProvider(
                        tenantId,             // OCID
                        userId,               // OCID
                        fingerprint,          // String
                        File privateKeyFile,
                        char[] passphrase)
    • For cloud configuration when application is running in the same region use instance principal authentication. This requires a one-time setup.

  • For cloud simulator use:
  • For on-prem configuration use one of the following examples or see documentation.

    • For unsecure example:

      new oracle.nosql.driver.kv.StoreAccessTokenProvider()
    • For secure example use:

      new oracle.nosql.driver.kv.StoreAccessTokenProvider("username", "password".toCharArray())

Note: For convenience one can use the following methods:

  • for cloud: NosqlDbConfig.createCloudConfig("endpoint", configFile);
  • for cloud simulator: NosqlDbConfig.createCloudSimConfig("endpoint");
  • for on-prem unsecure store: NosqlDbConfig.createProxyConfig("endpoint");
  • for on-prem secure store: NosqlDbConfig.createProxyConfig("endpoint", user, password);
  • Define the entity class:

    public class Customer {
        @NosqlId(generated = true)
        long customerId;
        String firstName;
        String lastName;
        public String toString() {
            return "Customer{" +
                "customerId=" + customerId +
                ", firstName='" + firstName + '\'' +
                ", lastName='" + lastName + '\'' +
  • Declare a repository that extends NosqlRepository:

    public interface CustomerRepository
        extends NosqlRepository<Customer, Long>
        Iterable<Customer> findByLastName(String lastname);
  • Write the main application class. This requires adding dependencies to org .springframework.boot:spring-boot and org.springframework .boot:spring-boot-autoconfigure.

    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.CommandLineRunner;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.context.ConfigurableApplicationContext;
    public class App implements CommandLineRunner
        private CustomerRepository repo;
        public static void main( String[] args )
                ctx =, args);
            SpringApplication.exit(ctx, () -> 0);
        public void run(String... args) throws Exception {
            Customer s1 = new Customer();
            s1.firstName = "John";
            s1.lastName = "Doe";
            System.out.println("\nsaved: " + s1); // customerId contains generated value
            Customer s2 = new Customer();
            s2.firstName = "John";
            s2.lastName = "Smith";
            System.out.println("\nsaved: " + s2); // customerId contains generated value
            Iterable<Customer> customers = repo.findAll();
            for (Customer s : customers) {
                System.out.println("  Customer: " + s);
            System.out.println("\nfindByLastName: Smith");
            customers = repo.findByLastName("Smith");
            for (Customer s : customers) {
                System.out.println("  Customer: " + s);

Build and run the example code

Example code requires an Oracle NoSQL DB instance and a local http proxy running on port 8080.

Start a kvlite instance with helperHosts "localhost:5000":

java -jar /path_to/kvstore.jar kvlite -root kvroot -host localhost -port 5000 -store kvstore -secure-config disable &

Start http proxy with endpoint URL "localhost:8080":

java -jar /path_to/httpproxy.jar -storeName kvstore -httpPort 8080 -helperHosts localhost:5000 -verbose true &

Execute the example code:

mvn exec:java -Dexec.mainClass=""

To log the internally generated queries, one has to enable the debug level by adding following logging flag:

mvn exec:java -Dexec.mainClass=""

Run unit tests

Running tests require a running store and proxy. The test.serverType and test.endpoint system properties must be specified.

mvn test -Dtest.serverType=onprem -Dtest.endpoint=

By default, if no option is specified, onprem serverType and http://127.0.0 .1:8080 endpoint is assumed.

Tests can be also be run on:

  • onprem:
    mvn -B -Ptest-onprem test -DargLine="-Dtest.endpoint=$ONPREM_ENDPOINT"
  • onprem-secure: Must specify the user, password, trustfile and trust file access password.
    mvn -B -Ptest-onprem-secure test -DargLine="-Dtest.endpoint=$ONPREM_SEC_ENDPOINT -Dtest.user=$DRIVER_USER$DRIVER_TRUST_FILE -Dtest.password=$DRIVER_PASS$DRIVER_TRUST_PASS"
  • cloudsim:
    mvn -B -Ptest-cloudsim test -DargLine="-Dtest.endpoint=$CLOUDSIM_ENDPOINT"


Copyright (c) 2020, 2024 Oracle and/or its affiliates. Released under the Universal Permissive License v1.0 as shown at

See the LICENSE file.

The THIRD_PARTY_LICENSES file contains third party notices and licenses.



When requesting help please be sure to include as much detail as possible, including version of the SDK and simple, standalone example code as needed.


This project welcomes contributions from the community. Before submitting a pull request, please review our contribution guide.


Please consult the security guide for our responsible security vulnerability disclosure process.