現在、私はシステム間のCachéに接続するために、次のコード(JDBCの道)を使用していますJavaバインドが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();
}
}
}
}
私はシステム間Cachéに接続するには、この方法(Javaのバインド)を使用したいと思いますが、私は私の環境で午前(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());
}
}
}
私は知っています、あなたの答えに感謝します。 –