Writing GIS software (and data) from scratch in Javaprobably isn't where you want to start.- V
private static void connectToSQLServer(){ try { IPropertySet propertySet = new PropertySet(); propertySet.setProperty("SERVER", "server name"); propertySet.setProperty("SERVERINSTANCE", "server instance name"); propertySet.setProperty("DATABASE", "database name"); propertySet.setProperty("DBCLIENT", "SQLServer"); propertySet.setProperty("USER", "sql server user name"); propertySet.setProperty("PASSWORD", "your password"); //propertySet.setProperty("AUTHENTICATION_MODE", "DBMS"); // Optional. DBMS is default //propertySet.setProperty("AUTHENTICATION_MODE", "OSA"); // Required if using operating sytem authentication IWorkspaceFactory workspaceFactory = new SqlWorkspaceFactory(); IWorkspace workspace = new Workspace(workspaceFactory.open(propertySet, 0)); IEnumDatasetName dsFeatureClassNames = workspace.getDatasetNames(esriDatasetType.esriDTAny); IDatasetName fcName = dsFeatureClassNames.next(); while (fcName != null){ System.out.println(fcName.getName()); fcName = dsFeatureClassNames.next(); } } catch (AutomationException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
// Create a propertySet that contains the connection information to ArcSDE // In ArcCatalog, the first three values are: server, service, database in the connection properties of the sde connection. IPropertySet propertySet = new PropertySet(); propertySet.setProperty("SERVER", "server name"); propertySet.setProperty("INSTANCE", "sde:sqlserver:server name"); propertySet.setProperty("DATABASE", "database name"); propertySet.setProperty("USER", "user name"); propertySet.setProperty("PASSWORD", "user password"); propertySet.setProperty("VERSION", "sde.DEFAULT"); // or whatever you call your version // Create a SdeWorkspaceFactory and open it IWorkspaceFactory sdeworkspaceFactory = new SdeWorkspaceFactory(); IWorkspace workspace = new Workspace(sdeworkspaceFactory.open(propertySet, 0));
ArcObjects Java API is still in play for connecting to your database.
I am trying to connect via direct connection to PostgreSQL spatial db. Java API version is 10.2 postgre 9.6 jdk 6. It successfully connects to database but when I call conn.getLayers() it says "Error getting layers" arcsde error -37 desc: DBMS TABLE DOES NOT EXIST. I dont know which table it is unable to find.
PostgreSQL 9.6 is not supported by geodatabases yet, so it can't have an Enterprise geodatabase, so ALL of the geodatabase tables are missing.
- V
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.