Skip to main content

Connecting Using CacheDataSource

The com.intersys.jdbc.CacheDataSource class provides the preferred approach to loading the database driver and creating a java.sql.Connection object.


public class JDBCExamples {
 public static Connection createConnection() 
 throws SQLException, ClassNotFoundException {
      CacheDataSource ds = new CacheDataSource();
      ds.setURL("jdbc:Cache://127.0.0.1:1972/USER");
      ds.setUser("_SYSTEM");
      ds.setPassword("SYS");
      Connection conn = ds.getConnection();
      return conn;
  }
}
Note:

For more information on using the Caché JDBC driver, including using a connection pool and DriverManager, read Establishing JDBC Connections in Using Caché with JDBC.

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