Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

クイックスタート : DBService.java


package basic;

import com.jalapeno.ApplicationContext;
import com.jalapeno.ObjectManager;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Iterator;


public class DBService{

private ObjectManager objectManager;

public DBService ()
      throws Exception
  {
        String           host = "localhost";
        String           username="_SYSTEM";  // null for default
        String           password="SYS";  // null for default

        String           url="jdbc:Cache://" + host + ":1972/USER";

        Class.forName ("com.intersys.jdbc.CacheDriver");
        Connection connection =  
                      DriverManager.getConnection (url, username, password);
        objectManager = ApplicationContext.createObjectManager (connection);
    }
 protected void saveContact(Contact contact )
 throws Exception
 {
    objectManager.save(contact, true);
       
 }
protected Iterator allContacts ()
throws Exception
 {
    return objectManager.openByQuery (Contact.class, null, null);
 }  

}     

FeedbackOpens in a new tab