Connect from ArcObjects 10.1 Java (1.5) to ArcSDE (10.1) + PostgreSQL (9.0.5)

2447
2
10-04-2012 07:52 AM
MarcosRodriguez_Gómez
New Contributor
Hi.

I'm developing a Java main app with ArcObjects 10.1, when I run this app and it tries to connect to ArcSDE 10.1 (over PostgreSQL 9.0.5) I get the following error:

AutomationException: 0x8004156b -
at com.esri.arcgis.datasourcesGDB.SdeWorkspaceFactory.open(Unknown Source)
at es.edb.prueba.conexiones.ConexionSDE.conectar(ConexionSDE.java:52)
at es.edb.prueba.principal.PruebaAO.main(PruebaAO.java:50)

If I change the PropertySet with ArcSDE 9.3.1 + Oracle 10g connection params it gets success.

What should I do for solving this problem? Should I intall PostgreSQL client in client machine? Where?

Thanks in advance,
Marcos.

My connection code:

...
        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();
     
  }
 }
...


Configuration:

Java 1.6
arcobjects.jar 10.1
ArcSDE 10.1
PostgreSQL 9.0.5
Server Operating System: W2003 Server Standard 64 bits
Client Operating System (where I run Java main app): Windows 7 Professional 64 bits
0 Kudos
2 Replies
LeoDonahue
Occasional Contributor III
Which line in your code is line #52?

My code is slightly different, but I see that you are using server contexts.

And I don't know what object gWS is, based on your sample.

        // 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));
0 Kudos
MarcosRodriguez_Gómez
New Contributor
Hi Leo.

My code line #52 is:

  
gWS = gWorkspaceFactory.open(propSet, 0);


I connect to ArcSDE 10.1 (+ PostgreSQL 9.0.5) from ArcCatalog and ArcMap without problem with the same connection params.

I change my sample connection code to clarify:

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();
     
  }
 }


Thanks,
Marcos.
0 Kudos