The example program is called UpdateJSON. We deliberately avoid using Java JSON APIs in this example so as to show how to perform these operations using Oracle NoSQL Database APIs only. Our imports are therefore limited to oracle.kv, oracle.kv.table, java.io, and java.util.

package table;

import oracle.kv.FaultException;
import oracle.kv.KVStore;
import oracle.kv.KVStoreConfig;
import oracle.kv.KVStoreFactory;
import oracle.kv.StatementResult;

import oracle.kv.table.FieldValue;
import oracle.kv.table.Index;
import oracle.kv.table.IndexKey;
import oracle.kv.table.MapValue;
import oracle.kv.table.PrimaryKey;
import oracle.kv.table.RecordValue;
import oracle.kv.table.Row;
import oracle.kv.table.Table;
import oracle.kv.table.TableAPI;
import oracle.kv.table.TableIterator;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import java.util.ArrayList;

public class UpdateJSON {
    private String dataFile = "person_contacts.json";
    private String defaulthost = "localhost:5000";
    private String helperhosts[];
    private String storeName = "kvstore";

    private static void usage() {
        String msg = "Creates a table and loads data into it from\n";
        msg += "an external file containing one or more JSON\n";
        msg += "objects. The objects must conform to the table\n";
        msg += "schema. Table rows are then updated so that\n";
        msg += "zipcodes for all home addresses in Boston are\n";
        msg += "modified updated. Update is performed 3 different\n";
        msg += "ways so as to illustrate the ways to query JSON\n";
        msg += "data in Oracle NoSQL Database.\n";
        msg += "\nCommand line options: \n";
        msg += "-store <storename>\n";
        msg += "\tName of the store. Defaults to 'kvstore'\n";
        msg += "-hostport <hostname>:<port>\n";
        msg += "\tStore location. Defaults to 'localhost:5000'\n";
        msg += "-file <filename>\n";
        msg += "\tFile containing row data. Defaults to ";
        msg += "person_contacts.json";


    public static void main(String args[]) {
        UpdateJSON uj = new UpdateJSON();