Skip to main content

Connecting to Caché

In order to use a Java projection to communicate with the Caché database, you must establish a database connection. There are two types of connections: Regular and Light. Light connections are faster than Regular connections, but support slightly less functionality.

Connection Type Details
Regular Connection
  • Supports the execution of methods, both class methods and instance methods, on the Caché Server

  • Supports the opening of multiple instances of an object simultaneously

  • Created using the getDatabase method of the com.intersys.objects.CacheDatabase

Light Connection
  • Faster than Regular Connections

  • Supports the execution of Caché class methods

  • Supports the execution of Caché instance methods that are persistence related or retrieve or update properties

  • Does not support the execution of Caché instance methods that are not persistence related or do more than merely retrieve or update properties

  • Does not support the opening of multiple instances of an object simultaneously

  • Created using the getLightDatabase method of the com.intersys.objects.CacheDatabase

The following Java client method uses getDatabase to create a regular connection. Notice that getDatabase throws a checked exception of type CacheException. It requires, as an argument, a url specifying the server IP address, the port number of the database, and the name of the Caché Namespace containing the data. The method also requires, as separate arguments, the username and password for the Caché namespace.


public class BindingExamples {
   public static Database createConnection() throws CacheException{
      String url="jdbc:Cache://localhost:1972/USER";
      String username="_SYSTEM";
      String pwd="SYS";
      Database db = CacheDatabase.getDatabase(url, username, pwd);
      return db;
   }
}
Note:

In general, the connection string for connecting to Caché has the following form: jdbc:Cache://<server>:<port>/<namespace>, where <server> is the IP address of the server hosting Caché, port is the SuperServer port number for your Caché instance, and namespace is the Caché namespace containing your Caché classes and data. Click the About link on the upper left-hand corner of the Management Portal to determine the SuperServer port number for your Caché instance. The default is 1972.

FeedbackOpens in a new tab