public static void main()

in jdbc/src/main/java/org/apache/geode_examples/jdbc/Example.java [33:69]


  public static void main(String[] args) {
    // connect to the locator using default port 10334
    ClientCache cache =
        new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334)
            .setPdxSerializer(
                new ReflectionBasedAutoSerializer("org.apache.geode_examples.jdbc.Parent"))
            .create();

    // create a local region that connects to the server region
    Region<Long, Parent> region =
        cache.<Long, Parent>createClientRegionFactory(ClientRegionShortcut.PROXY).create("Parent");
    System.out.println("Region=" + region.getFullPath());

    Example example = new Example(region);

    // Put entry in Parent region to verify it propagates to the external RDBMS table
    Long key = Long.valueOf(1);
    Parent value = new Parent(key, "Parent_1", Double.valueOf(123456789.0));
    region.put(key, value);
    System.out.println("Region.put() added an entry into Parent region. The key is " + key
        + ", and the value is " + value + ".");
    System.out.println(
        "If JDBC Connector is configured, the value will be persisted to external data source.");
    // Get an entry from Parent region that will trigger the cache loader to
    // retrieve the entry from the external table
    System.out.println(
        "Calling Region.get(). If JDBC Connector is configured, it will retrieve data from external data source and return a non-null value.");
    key = Long.valueOf(2);
    Parent parent = (Parent) region.get(key);
    System.out.println("The returned value of Region.get(" + key + ") is " + parent + ".");

    // Print the current entries in the region
    System.out.println("All entries currently in Parent region");
    example.printValues(example.getKeys());

    cache.close();
  }