Guest Post by:
Dave Rubin, Senior Director, NoSQL and Embedded Database Development, Oracle
The Oracle NoSQL Database Development team is thrilled to have the Oracle NoSQL Database Cloud Service fully integrated on the native Oracle Cloud Infrastructure.
In this post, I will walk through the steps to write a simple Hello World application using the recently integrated Oracle NoSQL Database Cloud Service. You will also see that writing your first Hello World application can be accomplished in 15 minutes or less. You may first be wondering, why use a NoSQL Database and what is the Oracle NoSQL Database Cloud Service? These are great questions and ones that I will discuss before getting into the code.
Modern application developers have many choices when faced with deciding when and how to persist a piece of data. In recent years, NoSQL databases have become increasingly popular and are now seen as one of the necessary tools in the toolbox that every application developer must have at their disposal. While tried and true relational databases are great at solving classic application problems like data normalization, strictly consistent data, and arbitrarily complex queries to access that data, NoSQL databases take a different approach.
Many of the more recent applications have been designed to personalize the user experience to the individual, ingest huge volumes of machine generated data, deliver blazingly fast, crisp user interface experiences, and deliver these experiences to large populations of concurrent users. In addition, these applications must always be operational, with zero down-time, and with zero tolerance for failure. The approach taken by Oracle NoSQL Database is to provide extreme availability and exceptionally predictable, single digit millisecond response times to simple queries at scale. The Oracle NoSQL Database Cloud Service is designed from the ground up for high availability, predictably fast responses, resiliency to failure, all while operating at extreme scale. Largely, this is due to Oracle NoSQL Database’s shared nothing, replicated, horizontal scale-out architecture and by using the Oracle NoSQL Database Cloud Service, Oracle manages the scale out, monitoring, tuning, and hardware/software maintenance, all while providing your application with predictable behavior.
The Oracle NoSQL Database Cloud Service is a server-less, fully managed data store that delivers predictable single digit response times and allows application to scale on demand via provisioning API calls. There are four simple steps to getting started with the Oracle NoSQL Database Cloud Service.
Furthermore, you can use your free cloud credits to do all of this and not pay a single penny.
Once you have created a cloud account, you can either navigate to the Oracle NoSQL Database table management console, or if you are like most developers, quickly move onto writing your first hello world code. For this release of the Oracle NoSQL Database Cloud Service, you can write your first hello world program using Python, Node.js, Java, or Go. Future releases of the service will support C++, C#, and other popular programming languages. I will use Java for the remainder of this blog. Java 8 and Java 11 are certified.
Since access to the Oracle NoSQL Cloud Service is via HTTP, you can run your application directly on your laptop and connect to the database service over the internet. While I would never recommend using the internet as a network transport for performance sensitive applications, it works perfectly for our hello world example. In fact, most likely you would want to deploy by running your application inside your own tenancy co-located in the same Oracle Cloud Infrastructure region as your NoSQL table and use the Oracle Cloud Infrastructure Service Gateway to connect to the NoSQL Cloud Service.
I’ll navigate my browser to the following URL https://www.oracle.com/downloads/cloud/nosql-cloud-java-driver-downloads.html, where I am presented with the following options:
I will choose the tar.gz file and download that one. Once you unbundle this file, you will see a lib directory which contains the Oracle NoSQL Cloud Service driver along with a few other dependent libraries. For this example, I am placing these files in /Users/drubin/NoSQL/oracle-nosql-java-sdk-5.2.11. Notice the contents of the lib directory. These are the only libraries that you will need to compile and run your hello world example.
The Oracle NoSQL Database Cloud Service uses the Oracle Cloud Infrastructure native cloud Identity Access Manager (IAM) for authentication and authorization. In the Javadoc (https://docs.oracle.com/en/cloud/paas/nosql-cloud/csnjv/index.html) for the driver, you will notice a new package entitled oracle.nosql.driver.iam, which currently contains a single class, SignatureProvider. We will use this class to provide our authentication information to the cloud service.
Before you can authenticate your application with the cloud service, you must generate a key pair and upload your public key to the Oracle Cloud. The instructions here will guide you through generating an API signing key and uploading the public key to the Oracle Cloud https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#How
The following information will be needed for you to successfully authenticate with the cloud service:
The code below is structured as follows:
If you take the code above and place it in a file entitled HelloWorld.java and you fill in your credentials in the getNoSQLConnection() method, you can compile this file as specified below:
and run the resulting class file as specified below (NOTE the JSON output from running the program):
You can also explore your tables using the Oracle Cloud Infrastructure console. On the left hand menu, simply navigate to the NoSQL Database menu item.
Once you click on the hello_world table link, you will see the following page:
Clicking on the Table rows control and then the clicking the Run query button control will display the record that you just inserted into the table:
If you have questions regarding this exercise, please send an email to email@example.com with “Hello World” in the subject line, and someone will get back to you as soon as possible.