@SergioSAS,
Below is an example of using the IDataSet interface, however, you may find it simpler to use JDBC instead.
import com.sas.iom.SAS.*; import com.sas.iom.SASIOMDefs.*; import com.sas.services.connection.*; import org.omg.CORBA.IntHolder; import org.omg.CORBA.StringHolder; import java.util.Arrays; public class SasOutputDataExample { public static void main(String... args) { ConnectionInterface cx = null; boolean failed = false; try { BridgeServer server = new BridgeServer(BridgeServer.CLSID_SAS, "sas.myhost.net", 8591); server.setEncryptionContent(BridgeServer.ENCRYPTION_CONTENT_ALL); server.setEncryptionAlgorithms(BridgeServer.ENCRYPTION_ALGORITHM_AES); server.setSecurityPackage(BridgeServer.SECURITY_PACKAGE_NEGOTIATE); server.setSecurityPackageList(BridgeServer.SECURITY_PACKAGE_LIST_DEFAULT); ManualConnectionFactoryConfiguration mconf = new ManualConnectionFactoryConfiguration(server); ConnectionFactoryManager manager = new ConnectionFactoryManager(); ConnectionFactoryInterface factory = manager.getFactory(mconf); SecurityPackageCredential cred = new SecurityPackageCredential(); cx = factory.getConnection(cred); } catch (ConnectionFactoryException err) { System.out.print(err.getMessage()); failed = true; } if (!failed) { IWorkspace workspace = IWorkspaceHelper.narrow(cx.getObject()); try { ILanguageService ls = workspace.LanguageService(); ls.Submit("data kids; set sashelp.class; run;"); ILibref libWork = workspace.DataService().UseLibref("work"); int flags = 0; StringHolder dataSetLabel = new StringHolder(); StringHolder dataSetType = new StringHolder(); DateTimeHolder dateCreated = new DateTimeHolder(); DateTimeHolder dateModified = new DateTimeHolder(); IntHolder recordLength = new IntHolder(); StringHolder compressionRoutine = new StringHolder(); IntHolder bookmarkLength = new IntHolder(); IntHolder logicalRecordCount = new IntHolder(); IntHolder physicalRecordCount = new IntHolder(); IntHolder attrs = new IntHolder(); IDataSet kids = libWork.OpenDataSet(flags, "kids", "", new String[]{"", "", ""}, dataSetLabel, dataSetType, dateCreated, dateModified, recordLength, compressionRoutine, bookmarkLength, logicalRecordCount, physicalRecordCount, attrs); int bindKey = 0; byte[] positionBookmark = new byte[]{}; int numberRowsToRead = 2; int rowsOffset = 0; VariableArray2dOfStringHolder characterValues = new VariableArray2dOfStringHolder(); VariableArray2dOfDoubleHolder numericValues = new VariableArray2dOfDoubleHolder(); VariableArray2dOfOctetHolder missingValues = new VariableArray2dOfOctetHolder(); OctetSeqHolder bookmarks = new OctetSeqHolder(); IntHolder status = new IntHolder(); kids.ReadRecords(flags, bindKey, positionBookmark, numberRowsToRead, rowsOffset, characterValues, numericValues, missingValues, bookmarks, status); for (int i = 0; i < numberRowsToRead; i++) { System.out.println(Arrays.toString(characterValues.value[i])); //character values are formatted } workspace.Close(); cx.close(); } catch (Exception err) { err.printStackTrace(); } } } }
This should then print the following to the console
[Alfred , M, Alfred , M, 14, 69, 112.5]
[Alice , F, Alice , F, 13, 56.5, 84]
IDataSet can also provide you with the metadata for the data set (i.e. Column Names, etc...)
... View more