importjava.io.IOException;importjavax.swing.JFrame;importcom.esri.arcgis.system.AoInitialize;importcom.esri.arcgis.system.EngineInitializer;importcom.esri.arcgis.datasourcesGDB.SdeWorkspaceFactory;importcom.esri.arcgis.geodatabase.*;importcom.esri.arcgis.system.*;publicclassDataImport {publicstaticvoidmain(String[] args)
{
getSDETable();
}publicstaticvoidgetSDETable() {try{
initializeArcGISLicenses();
SdeWorkspaceFactory sdeFact=newSdeWorkspaceFactory();//Create a PropertySet object that will contain all of the//SDE connection parametersPropertySet propSet=newPropertySet();//Populate the property set with the connection parameterspropSet.setProperty("SERVER","192.168.2.24");
propSet.setProperty("INSTANCE","5151");
propSet.setProperty("DATABASE","testsde");
propSet.setProperty("USER","sde");
propSet.setProperty("PASSWORD","wt");
propSet.setProperty("VERSION","sde.DEFAULT");//Open the ArcSDE workspace using the connection PropertySetWorkspace ws=newWorkspace(sdeFact.open(propSet,0));//Get the collection of dataset names in the database and display their namesIEnumDatasetName dsNames=ws
.getDatasetNames(esriDatasetType.esriDTAny);
IDatasetName name=dsNames.next();while(name!=null) {
System.out.println(name.getName());
name=dsNames.next();
}
}catch(IOException e) {
e.printStackTrace();
}
}staticvoidinitializeArcGISLicenses() {try{
EngineInitializer.initializeEngine();
com.esri.arcgis.system.AoInitialize ao=newcom.esri.arcgis.system.AoInitialize();if(ao.isProductCodeAvailable(com.esri.arcgis.system.esriLicenseProductCode.esriLicenseProductCodeEngine)==com.esri.arcgis.system.esriLicenseStatus.esriLicenseAvailable)
ao.initialize(com.esri.arcgis.system.esriLicenseProductCode.esriLicenseProductCodeEngine);
}catch(Exception e) {
e.printStackTrace();
}
}
}