SAS9-IT Technology Application - Access SAS instances via Java

xiaoxiao2021-03-06  63

After configuring the SAS's IT, it allows Java to access IT through Bridge technology, write a test example below, perform Data STEP via Java, and get returned log information

//Untitled1.java

Import com.sas.iom.sas.iworkspace; import com.sas.iom.sas.iworkspacehelper; import com.sas.iom.sas.ilanguageService; import com.sas.iom.sas.ilanguageService; import com.sas.iom .SAS.ILanguageServicePackage.CarriageControlSeqHolder; import com.sas.iom.SAS.ILanguageServicePackage.LineTypeSeqHolder; import com.sas.iom.SAS.IWorkspace; import com.sas.iom.SASIOMDefs.StringSeqHolder; import com.sas.services.connection .BridgeServer; import com.sas.services.connection.ConnectionFactoryAdminInterface; import com.sas.services.connection.ConnectionFactoryConfiguration; import com.sas.services.connection.ConnectionFactoryInterface; import com.sas.services.connection.ConnectionFactoryManager; import com. Sas.Services.connection.connectionInterface; import com.sas.services.Connection.manualConnectionFactoryConfiguration; import com.soServices.connection.server;

Import java.util. *; import java.io. *; import java.io.datainputstream; import java.io.Dataoutputstream;

PUBLIC CLASS Untitled1 {Public Untitled1 () {}

Static public void main (string [] argv) {

// identify the IOM server String classID = Server.CLSID_SAS; String host = "wuyz"; int port = 8591; Server server = new BridgeServer (classID, host, port); try {// make a connection factory configuration with the server ConnectionFactoryConfiguration cxfconfig = New ManualConnectionFactoryConfiguration (server);

// Get a connection factory manager connectionFactoryManager CXFManager = new connectionFactoryManager ();

// get a connection factory that matches the configuration ConnectionFactoryInterface cxf = cxfManager.getFactory (cxfConfig); // get the administrator interface ConnectionFactoryAdminInterface admin = cxf.getAdminInterface ();

// Get a connection string username = "sasadm"; string password = "sas"; system.out.println ("-------------------- connnect .... "); connectioninterface cx = cxf.getConnection; org.omg.corba.object obj = cx.getObject (); iWorkspace iWorkspace = iWorkspaceHelper.narrow (OBJ);

IlanguageService Saslanguage = iWorkspace.LanguageService (); / * Excute a examle data step. * / Saslanguage.submit ("DATA A; X = 1; Run; Proc Print; Run;");

/ * Get SAS log * / CarriageControlSeqHolder logCarriageControlHldr = new CarriageControlSeqHolder ();. LineTypeSeqHolder logLineTypeHldr = new LineTypeSeqHolder (); StringSeqHolder logHldr = new StringSeqHolder (); sasLanguage.FlushLogLines (Integer.MAX_VALUE, logCarriageControlHldr, logLineTypeHldr, logHldr); String [] logLines = logHldr.value; CarriageControlSeqHolder listCarriageControlHldr = new CarriageControlSeqHolder (); LineTypeSeqHolder listLineTypeHldr = new LineTypeSeqHolder (); StringSeqHolder listHldr = new StringSeqHolder (); sasLanguage.FlushListLines (Integer.MAX_VALUE, listCarriageControlHldr, listLineTypeHldr, listHldr); String [] listLines = Listhldr.Value;

System.out.println ("----------------------------- -------- "); for (int i = 0; i

// Tell The factory That It can destroy unused connections admin.shutdown (); system.out.println ("------------------- is Shutdown. ... ");} catch (exception e) {E.PrintStackTrace ();}}

转载请注明原文地址:https://www.9cbs.com/read-112693.html

New Post(0)