Java Bind 连接到Caché 代码已被弃用,如何替换?

Java Bind connected to the Caché code has been deprecated, how to replace?

目前,我使用以下代码(JDBC方式)连接到InterSystem Caché:

import java.sql.*;

import com.intersys.jdbc.CacheDataSource;

/**
 * @author prd
*/
public class NewTinyBind {

public static void main(String[] args) {
    Connection dbconnection = null;
    Statement stmt = null;
    try {
        String url = "jdbc:Cache://localhost:1972/SIMPLE";
        String username = "_SYSTEM";
        String password = "SYS";
        CacheDataSource cds = new CacheDataSource();
        cds.setURL(url);
        dbconnection = cds.getConnection(username, password);
        stmt = dbconnection.createStatement();
        java.sql.ResultSet rs = stmt.executeQuery(" SELECT * FROM TEST ");
        int cols = rs.getMetaData().getColumnCount();
        while (rs.next()) {
            for (int i = 1; i < cols + 1; i++) {
                String colname = rs.getMetaData().getColumnName(i);
                Object value = rs.getObject(i);
                System.out.println("colname:" + colname + ",value:" + value);
            }
        }
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        try {
            stmt.close();
            dbconnection.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

}

我想用这种方式(Java Bind)连接InterSystem Caché,但是我在我的环境(jdk 1.8)下,提示以下代码过时( @java.lang.Deprecated), 但是文件没有提示如何替换这些过时的代码,有人知道吗?谢谢。

代码由 https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=BLJV_using#BLJV_using_objects_sample

import java.io.*;
import java.util.*;
import com.intersys.objects.*;

public class SampleApplication {
  public static void main(String[] args){
      Database dbconnection = null;
      String url="jdbc:Cache://localhost:1972/SAMPLES";
      String username="_SYSTEM";
      String password="sys";
      ObjectServerInfo info = null;
      Sample.Person person = null;

      try {
          // Connect to Cache on the local machine, in the SAMPLES namespace
          dbconnection = CacheDatabase.getDatabase (url, username, password);

          // Open an instance of Sample.Person,
          // whose ID is read in from the console
          InputStreamReader isr = new InputStreamReader(System.in);
          BufferedReader br = new BufferedReader(isr);
          System.out.print("Enter ID of Person object to be opened:");
          String strID = br.readLine();

          // Use the entered strID as an Id and use that Id to
          // to open a Person object with the _open() method inherited
          // from the Persistent class. Since the _open() method returns
         // an instance of Persistent, narrow it to a Person by casting.
          person = (Sample.Person)Sample.Person._open(dbconnection, new Id(strID));

          // Fetch some properties of this object
          System.out.println("Name: " + person.getName());
          System.out.println("City: " + person.getHome().getCity());

          // Modify some properties
          person.getHome().setCity("Ulan Bator");

          // Save the object to the database
          person._save();

          // Report the new residence of this person */
          System.out.println( "New City: " + person.getHome().getCity());

          /* de-assign the person object */
          dbconnection.closeObject(person.getOref());
          person = null;

          // Close the connection
          dbconnection.close();

    } catch (Exception ex) {
      System.out.println("Caught exception: "
        + ex.getClass().getName()
        + ": " + ex.getMessage());
    }
  }
}

InterSystems 开发人员社区门户上的 same question。 文档 says

Important:

The Caché Java Binding is Deprecated
Java Persistence Architecture (JPA) is the recommended persistence technology for complex object hierarchies in Java projects. Caché and Ensemble currently support JPA 1.0 and 2.0 via the Hibernate implementations of the JPA specifications. See “Using the Caché Hibernate Dialect” in Using Caché with JDBC.

Extreme Event Persistence (XEP) is the recommended persistence technology for high-performance simple to medium complexity object hierarchies in Java projects. See “Using eXTreme Event Persistence” in Using Java with Caché eXTreme.