Using Java with Caché
The Caché Java Binding
[Back] [Next]
   
Server:docs2
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

The Caché Java binding provides a simple, direct way to use Caché objects within a Java application. You can create Java applications that work with the Caché database in the following ways:

This document assumes a prior understanding of Java and the Java standard library. Caché does not include a Java compiler or development environment.
Java Binding Architecture
The Caché Java binding gives Java applications a way to access and manipulate objects contained within a Caché server. These objects can be persistent objects stored within the Caché database or they can be transient objects that perform operations within a Caché server.
The Caché Java binding consists of the following components:
The Caché Class Compiler can automatically create Java client classes for any classes contained within the Caché Class Dictionary. These generated Java classes communicate at runtime with their corresponding Caché class on a Caché server. The generated Java classes contain only pure Java code and are automatically synchronized with the master class definition. This is illustrated in the following diagram:
Java Client/Server Architecture
The basic mechanism works as follows:
The runtime architecture consists of the following:
Installation and Configuration
All applications using the Caché Java binding are divided into two parts: a Caché server and a Java client. The Caché server is responsible for database operations as well as the execution of Caché object methods. The Java client is responsible for the execution of all Java code (such as additional business logic or the user interface). When an application runs, the Java client connects to and communicates with a Caché server via a TCP/IP socket. The actual deployment configuration is up to the application developer: the Java client and Caché server may reside on the same physical machine or they may be located on different machines. Only the Caché server machine requires a copy of Caché.
Java Client Requirements
InterSystems Supported Platforms specifies the current requirements for all Java-based binding applications:
The core components of the Java binding are files named cache-jdbc-2.0.0.jar and cache-db-2.0.0.jar, which contain the Java classes that provide the connection and caching mechanisms for communication with the Caché server, JDBC connectivity, and reflection support. Client applications do not require a local copy of Caché, but the cache-jdbc-2.0.0.jar and cache-db-2.0.0.jar files must be on the class path of the application when compiling or using Java proxy classes. See The Caché Java Class Packages for more information on these files.
Very little configuration is required to use a Java client with a Caché server. The Java sample programs provided with Caché should work with no change following a default Caché installation. This section describes the server settings that are relevant to Java and how to change them.
Every Java client that wishes to connect to a Caché server needs a URL that provides the server IP address, port number, and Caché namespace, plus a username and password.
The Java sample programs use the following connection information:
   String url = "jdbc:Cache://127.0.0.1:1972/SAMPLES";
   String user = "_SYSTEM";
   String password = "SYS";
To run a Java or JDBC client application, make sure that your installation meets the following requirements:
The Caché Java Class Packages
The files containing the Caché Java class packages are located in <install-dir>\Dev\java\lib\<java-release>, where <install-dir> is the root directory of your Caché installation and <java-release> corresponds to the Java JDK you are using. See Caché Installation Directory in the Caché Installation Guide for the location of <install-dir> on your system. For supported Java releases, see “Supported Java Technologies” in InterSystems Supported Platforms.
The Java class packages are contained in the following files:
See the JavaDoc in <install-dir>\dev\java\doc\ for the latest and most complete description of these packages.
Tutorials and Other Documentation
The standard Caché installation provides a tutorial, JavaDoc, and several other documents describing various ways to use Java with Caché.