Introduction

This example demonstrates using secondary store notifiers to integrate with a JDBC data base.

Please see the enclosed source and javadoc for the JDBC example.

Overview

The JDBC (Java Database Connectivity) example demonstrates how to use secondary store notifiers to integrate with a JDBC database. The example implements all of the secondary store notifiers and then performs modifications and queries against Managed Objects to trigger the installed notifiers.

The secondary store notifiers perform the required database connection and transaction management to transactionally perform actions against the database.

A named cache is also defined to demonstrate how to use a named cache to control the number of objects stored in shared memory.

Functional Description

The JDBC example does the following:

  1. Creates and populates the account table in the fluencyjdbc database.
  2. Installs secondary store notifiers.
  3. Initializes a named cache for the Account Managed Objects.
  4. Demonstrates how duplicate key errors are handled.
  5. Performs queries and modifications to the Account objects which trigger the secondary store notifiers to transactionally perform the requested database action against the account table.

Database Description

This example creates and uses the fluencyjdbc database.

An account database table will be created in the fluencyjdbc database with the following SQL commands:

create table account (
        accountnumber INT UNSIGNED,
        balance FLOAT)

create unique index account_index on account (accountnumber)

Java Class Description

The following classes are used in this example:

Deployment

Client Configuration

The example can be built and run directly using the deployment tool, or using the Maven deployment plugin.

See the Deployment Maven Plugin documentation for more information on configuring the client connectivity.

Database Provider

The main method requires a JDBC url to a MySQL database as the first argument.

The example expects to find an account table in the fluencyjdbc database. The enclosed POM binds the database setup to the process-test-resources lifecycle phase.

This project uses the deploy:exec target to invoke main. To specify the connectivity to the MySQL server, set the properties example.mysqlhost and example.mysqlport.

Here is an example using the Maven deployment plugin where the MySQL database server and the domain manager node are running on the localhost.

mvn -Dexample.mysqlhost=localhost \
    -Dexample.mysqlport=3306 \
    -Dcom.kabira.fluency.hostName=localhost \
    -Dcom.kabira.fluency.administrationPort=2000 \
    -Dcom.kabira.fluency.domainNode=A \
    process-test-resources compile deploy:exec

To drop the fluencyjdbc database, use the clean binding:

mvn -Dexample.mysqlhost=localhost \
    -Dexample.mysqlport=3306 \
    clean

Dependencies

See the Dependencies page for information on the example's dependencies.

For each dependency listed in the Project Dependencies section of the Dependencies page, the example's POM (or parent POM) defines a property specifying the version of the dependency used by the example. These properties can be overridden if there is a need to change the dependency versions used by the example.

The names of these properties are of the form com.tibco.groupId.artifactId.version where groupId and artifactId are the group id and artifact id of the dependency. For example, the property named com.tibco.com.tibco.ast.version specifies the version of the dependency with the group id of com.tibco and the artifact id of ast.