/** * Connect to ArcSDE and initiate printing meta-data for feature classes and sde tables. */ private static void connectToSDE(){ try { // Create a propertySet that contains the connection information to ArcSDE IPropertySet propertySet = new PropertySet(); propertySet.setProperty("SERVER", "server name"); propertySet.setProperty("INSTANCE", "instance name"); propertySet.setProperty("DATABASE", "database name"); propertySet.setProperty("USER", "user name"); propertySet.setProperty("PASSWORD", "user password"); propertySet.setProperty("VERSION", "sde.DEFAULT"); // Create a SdeWorkspaceFactory and open it IWorkspaceFactory sdeworkspaceFactory = new SdeWorkspaceFactory(); IWorkspace workspace = new Workspace(sdeworkspaceFactory.open(propertySet, 0)); // --------------------------------------------------------------------------------------- // Iterate over all feature classes : esriDTFeatureClass // --------------------------------------------------------------------------------------- // Get the collection of featureclass data set names in the database and display their names. IEnumDatasetName dsFeatureClassNames = workspace.getDatasetNames(esriDatasetType.esriDTFeatureClass); // Add the data set names to an ArrayList that we will sort as a Collection ArrayList<String> featureclassDatasetNames = new ArrayList<String>(); IDatasetName fcName = dsFeatureClassNames.next(); while (fcName != null){ featureclassDatasetNames.add(fcName.getName()); fcName = dsFeatureClassNames.next(); } // Sort the ArrayList Collections.sort(featureclassDatasetNames); // Iterate over the set and call the displayFeatureClassMetadata method for(Object y : featureclassDatasetNames){ writer.append(y.toString()); writer.append(""); writer.append("--------------------"); writer.append(""); displayFeatureClassMetadata(workspace, y.toString()); } // --------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------- // Iterate over all tables : esriDTTable // --------------------------------------------------------------------------------------- // Get the collection of Table data set names in the database and display their names. IEnumDatasetName dsTableNames = workspace.getDatasetNames(esriDatasetType.esriDTTable); // Add the data set names to an ArrayList that we will sort as a Collection ArrayList<String> tableDatasetNames = new ArrayList<String>(); IDatasetName name = dsTableNames.next(); while (name != null){ tableDatasetNames.add(name.getName()); name = dsTableNames.next(); } // Sort the ArrayList Collections.sort(tableDatasetNames); // Iterate over the set and call the displayTableMetadata method for(Object y : tableDatasetNames){ writer.append(y.toString()); writer.append(""); writer.append("--------------------"); writer.append(""); displayTableMetadata(workspace, y.toString()); } // --------------------------------------------------------------------------------------- } catch (AutomationException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.