Skip to main content

Introduction to Caché JDBC

Caché provides a high-performance type 4 JDBC database driver. The Caché JDBC driver is fully compliant with the JDBC 4.1 API, supporting all required interfaces and adhering to all JDBC 4.1 guidelines and requirements.

The online InterSystems Supported PlatformsOpens in a new tab document for this release specifies the current requirements for all Java-based binding applications:

  • See “Supported Java Technologies” for supported Java releases.

  • See “Supported Client Platforms” for supported JDBC client platforms.

  • If your client application and the Caché server are not running on the same version of Caché, see “Supported Version Interoperability” for information on compatibility between versions.

You can use the Caché JDBC driver and SQL when you want to access your Caché data using a relational model. The Java Binding mechanism also uses the JDBC driver. You can mix relational and object-oriented database access to provide maximum flexibility to your application.

Using the JDBC Driver

The Caché JDBC driver is contained in cache-jdbc-2.0.0.jar. See “The Caché Java Class Packages” for information on using this file.

JavaDoc class documentation for the packages in cache-jdbc-2.0.0.jar is located in <install-dir>\dev\java\doc.

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

The Caché Java client requires the Java JDK, version 1.7 or higher. Client applications do not require a local copy of Caché.

The online InterSystems Supported PlatformsOpens in a new tab document for this release specifies the current requirements for all Java-based binding applications:

  • See “Supported Java Technologies” for supported Java releases.

  • See “Supported Client Platforms” for supported Java client platforms.

  • If your client application and the Caché server are not running on the same version of Caché, see “Supported Version Interoperability” for information on compatibility between versions.

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.

Caché Server Configuration

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, TCP 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 client must be able to access a machine that is currently running a compatible version of the Caché server (see “Supported Version Interoperability” in the online InterSystems Supported PlatformsOpens in a new tab document for this release. The client and the server can be running on the same machine.

  • Your class path must include the versions of cache-jdbc-2.0.0.jar and cache-db-2.0.0.jar that correspond to the client version of the Java JDK (see “The Caché Java Class Packages”).

  • To connect to the Caché server, the client application must have the following information:

    • The IP address of the machine on which the Caché SuperServer is running. The Java sample programs use the address of the server on the local machine (localhost or 127.0.0.1). If you want a sample program to connect to a different system you will need to change its connection string and recompile it.

    • The TCP port number on which the Caché SuperServer is listening. The Java sample programs use 1972 (the default). If you want a sample program to use a different port you will need to change its connection string and recompile it.

    • A valid SQL username and password. You can manage SQL usernames and passwords on the System Administration > Security > Users page of the Management Portal. The Java sample programs use the administrator username, "_SYSTEM" and the default password "SYS" or "sys". Typically, you will change the default password after installing the server. If you want a sample program to use a different username and password you will need to change it and recompile it.

    • The server namespace containing the classes and data that your client application will use. The Java samples connect to the SAMPLES namespace, which is pre-installed with Caché.

    See “Establishing JDBC Connections” for detailed information on connecting to the Caché server.

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 the online InterSystems Supported PlatformsOpens in a new tab document for this release.

The Java class packages are contained in the following files:

  • cache-jdbc-2.0.0.jar — all of the other files in this list are dependent on this file. It can be used by itself for JDBC binding applications.

  • cache-db-2.0.0.jar — required for most Java binding applications.

  • cache-extreme-2.0.0.jar — required only for Caché XEP binding applications (see Using Java with Caché XEP).

  • cache-gateway-2.0.0.jar — required for JDBC SQL Gateway applications (see “Using the Caché SQL Gateway with JDBC”).

See the JavaDoc in <install-dir>\dev\java\doc\ for the latest and most complete description of these packages.

FeedbackOpens in a new tab