... public void conectar() { PropertySet propSet = null; try { // Create a WorkspaceFactory object within the Server's context gWorkspaceFactory = (SdeWorkspaceFactory) ConexionAGS.crearObjeto(SdeWorkspaceFactory.getClsid()); // Create an instance of a PropertySet for an Oracle ArcSDE connection. // The PropertySet acts as an array of keyed values that ArcSDE will use to collect // the connection values from: propSet = (PropertySet) ConexionAGS.crearObjeto(PropertySet.getClsid()); propSet.setProperty("SERVER", "my_server_name"); propSet.setProperty("INSTANCE", "5151"); propSet.setProperty("DATABASE", "arcsde"); propSet.setProperty("USER", "sde"); propSet.setProperty("PASSWORD", "passwordsde"); propSet.setProperty("VERSION", "SDE.DEFAULT"); // Open the ArcSDE workspace and get a handle to it through the WorkspaceFactory, // passing in the PropertySet gWS = gWorkspaceFactory.open(propSet, 0); Cleaner.release(propSet); // You now have a connection to the database through a Workspace object (gWS). } catch (Exception e) { e.printStackTrace(); } } ...
// 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));
gWS = gWorkspaceFactory.open(propSet, 0);
public void conectar(ParametrosSDE parametrosConexion) { try { // Create a WorkspaceFactory object within the Server's context IWorkspaceFactory gWorkspaceFactory = (SdeWorkspaceFactory) ConexionAGS.crearObjeto(SdeWorkspaceFactory.getClsid()); // Create an instance of a PropertySet for an Oracle ArcSDE connection. // The PropertySet acts as an array of keyed values that ArcSDE will use to collect // the connection values from: PropertySet propSet = (PropertySet) ConexionAGS.crearObjeto(PropertySet.getClsid()); propSet.setProperty("SERVER", "my_server_name"); propSet.setProperty("INSTANCE", "5151"); propSet.setProperty("DATABASE", "arcsde"); propSet.setProperty("USER", "sde"); propSet.setProperty("PASSWORD", "passwordsde"); propSet.setProperty("VERSION", "SDE.DEFAULT"); // Open the ArcSDE workspace and get a handle to it through the WorkspaceFactory, // passing in the PropertySet IWorkspace gWS = gWorkspaceFactory.open(propSet, 0); Cleaner.release(propSet); // You now have a connection to the database through a Workspace object (gWS). } catch (Exception e) { e.printStackTrace(); } }