shrug-l: RE: ArcObjects / Oracle12c / EZCONNECT [solved]

Pollock, William H. (Bill) William.H.Pollock at dep.state.fl.us
Tue May 5 16:35:13 EDT 2015


Hello again, again, SHRUG -


First, thank you to April Williford, Zack Wetzel, Paul O'Rourke, and Satyam Patel for helping!

Second, here is/are the solutions:


Summary

-    It was the connection property parameter names.

-    DB_CONNECTION_PROPERTIES vs. DATABASE_CONNECTION_PROPERTIES

-    While some of the geodatabase examples use "DB_CONNECTION_PROPERTIES", the help documentation/description uses "DATABASE_CONNECTION_PROPERTIES".

-    In similar scenarios, use DB_CONNECTION_PROPERTIES, not DATABASE_CONNECTION_PROPERTIES.


Target Solution
// Using Oracle "Easy Connect" connection string.
// Create a DB connection string with connection properties.
string connStringBtlds = "DB_CONNECTION_PROPERTIES=server:port/service;DBCLIENT=oracle;USER=user;password=pass";
// Open the database using the connection string.
IWorkspace workspace = workspaceFactory.OpenFromString(connStringBtlds, 0);


Alternative Solution 1
// Using Oracle "Easy Connect" connection properties.
// Create a DB connection property set and populate it with connection properties.
IPropertySet propertySet = new PropertySetClass();
propertySet.SetProperty("DB_CONNECTION_PROPERTIES", "user/pass at server:port/service"); //this is the Oracle "Easy Connect" string
propertySet.SetProperty("DBCLIENT", "oracle");
propertySet.SetProperty("USER", "user");
propertySet.SetProperty("PASSWORD", "pass");
// Open the database using the property set.
IWorkspace workspace = workspaceFactory.Open(propertySet, 0);


Alternative Solution 2
// Using "traditional" connection properties.
// Create a property set and populate it with connection properties.
IPropertySet propertySet = new PropertySet();
propertySet.SetProperty("SERVER", "server");
propertySet.SetProperty("INSTANCE", "sde:oracle$server:port/service");
propertySet.SetProperty("DATABASE", "");
propertySet.SetProperty("USER", "user");
propertySet.SetProperty("PASSWORD", "pass");
// Open the database using the property set.
IWorkspace workspace = workspaceFactory.Open(propertySet, 0);


Cheers,
+ bill

William Pollock, GISP
Kyra Solutions, Inc.
FL Department of Environmental Protection
850.245.2722 ext. 4722


From: Pollock, William H. (Bill)
Sent: Tuesday, May 05, 2015 1:25 PM
To: 'shrug-l at lists.dep.state.fl.us'
Subject: RE: ArcObjects / Oracle12c / EZCONNECT

Hello again SHRUG -

Well, I think we got it mostly resolved; a misuse of connection properties.
The code snippets below should shed the light.

So can now programmatically pass all of the db connection properties necessary, including the Easy Connect string.
HOWEVER, I still have an issue where the Database Connection dialog appears and must be manually "OK'd" to initiate connection.

The Database Connection dialog was not appearing previously when using the "traditional" connection properties to connect to Oracle11g.
So if you have any thoughts, I am all ears.

Thank you.
+ bill

William Pollock, GISP
Kyra Solutions, Inc.
FL Department of Environmental Protection
850.245.2722 ext. 4722


CODE SNIPPET BEFORE
-------------------
/// Using "traditional" connection properties.
/// Create an SDE connection property set and populate it with connection properties.
IPropertySet propertySet = new PropertySetClass();
propertySet.SetProperty("SERVER", "server");
propertySet.SetProperty("INSTANCE", "instance"); //this is where i was trying to pass the Oracle Easy Connect string
propertySet.SetProperty("DATABASE", "");
propertySet.SetProperty("USER", "user");
propertySet.SetProperty("PASSWORD", "pass");
propertySet.SetProperty("VERSION", "sde.DEFAULT");
/// Open the geodatabase using the property set.
IWorkspace workspace = workspaceFactory.Open(propertySet, 0);

CODE SNIPPET AFTER
-------------------
/// Using Oracle "Easy Connect" connection string.
/// Create a DB connection property set and populate it with connection properties.
IPropertySet propertySet = new PropertySetClass();
propertySet.SetProperty("DATABASE_CONNECTION_PROPERTIES", "user/pass at server:port/service"); //this is the Oracle Easy Connect string
//propertySet.SetProperty("DBCLIENT", "oracle");
//propertySet.SetProperty("USER", "user");
propertySet.SetProperty("PASSWORD", "pass");
/// Open the database using the property set.
IWorkspace workspace = workspaceFactory.Open(propertySet, 0);



From: Pollock, William H. (Bill)
Sent: Tuesday, May 05, 2015 8:37 AM
To: 'shrug-l at lists.dep.state.fl.us'
Subject: ArcObjects / Oracle12c / EZCONNECT

Hello SHRUG -

i am having some trouble connecting to Oracle12c via ArcObjects and EZCONNECT.

Results so far:

*         Can connect via ArcCatalog 10.2.2 using an *.sde file. (EZCONNECT)

*         Can connect via ArcObjects using an *.sde file. (WorkspaceFactory2.OpenFromFile)

*         Cannot connect via ArcObjects using a connection property set. (WorkspaceFactory2.Open)

*         Cannot connect via ArcObjects using a connection string. (WorkspaceFactory2.OpenFromString)

Can someone offer any pointers?

Supporting info:


*         Oracle FAQ on EZCONNECT
http://www.orafaq.com/wiki/EZCONNECT


*         ESRI Blog on Easy Connect
http://blogs.esri.com/esri/supportcenter/2012/10/10/easy-connect-connecting-to-arcsde-just-got-easier/

Thank you.
+ bill

William Pollock, GISP
Kyra Solutions, Inc.
FL Department of Environmental Protection
850.245.2722 ext. 4722

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.dep.state.fl.us/pipermail/shrug-l/attachments/20150505/80a20942/attachment.htm


More information about the SHRUG-L mailing list