java连接sde的问题


// Create the SdeWorkspaceFactory
try {
SdeWorkspaceFactory sdeFact = new SdeWorkspaceFactory();
// Create a PropertySet object that will contain all of the
// SDE connection parameters
PropertySet propSet = new PropertySet();

// Populate the property set with the connection parameters
propSet.setProperty("SERVER", "192.168.222.128");
propSet.setProperty("INSTANCE", "5151");
propSet.setProperty("DATABASE", "sde");
propSet.setProperty("USER", "sde");
propSet.setProperty("PASSWORD", "sde");
propSet.setProperty("VERSION", "sde.DEFAULT");

// Open the ArcSDE workspace using the connection PropertySet
Workspace ws = new Workspace(sdeFact.open(propSet, 0));

// Get the collection of dataset names in the database and display their names
IEnumDatasetName dsNames = ws.getDatasetNames(esriDatasetType.esriDTAny);

IDatasetName name = dsNames.next();
while (name != null) {
System.out.println(name.getName());
name = dsNames.next();
}
} catch (IOException e) {
e.printStackTrace();
}

总是报错误


Could not load native libraries. ArcGIS/bin should be added to the system PATH environment variable.
java.lang.UnsatisfiedLinkError: no ntvauth in java.library.path
java.lang.UnsatisfiedLinkError: no ntvauth in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
at com.esri.arcgis.interop.NativeLoader.loadLibrary(Unknown Source)
at com.esri.arcgis.interop.NativeAuth.c(Unknown Source)
at com.esri.arcgis.interop.c.a(Unknown Source)
at com.esri.arcgis.interop.bc.a(Unknown Source)
at com.esri.arcgis.interop.jb.a(Unknown Source)
at com.esri.arcgis.interop.Dispatch.createDispatch(Unknown Source)
at com.esri.arcgis.interop.Dispatch.<init>(Unknown Source)
at com.esri.arcgis.geodatabase.IWorkspaceFactoryProxy.<init>(Unknown Source)
at com.esri.arcgis.datasourcesGDB.SdeWorkspaceFactory.<init>(Unknown Source)
at com.esri.arcgis.datasourcesGDB.SdeWorkspaceFactory.<init>(Unknown Source)
at com.dist.FlexGIS.Operation.main(Operation.java:24)

查找了很多资料,有人说需要把ntvauth.dll加到path环境变量中,但是我没有找到ntvauth.dll,请高手赐教ntvauth.dll 在什么位置,需要装什么软件吗,我已经安装了server(java),engine(java,。net)和sde了。

解决方案:
把Server初始化一下就可以了
提供一个参考代码

ServerInitializer serverInitializer = new ServerInitializer();
serverInitializer.initializeServer("workgroup", "arcgismanager", "1");
ServerConnection connection = new ServerConnection();
connection.connect("192.168.222.128");
IServerObjectManager som = connection.getServerObjectManager();
IServerContext context = som.createServerContext("HY","MapServer");
// Create a PropertySet object that will contain all of the
// SDE connection parameters
IPropertySet propSet = (PropertySet)context.createObject(PropertySet.getClsid());//new PropertySet();
// IPropertySet propSet = new PropertySet();
// Populate the property set with the connection parameters
propSet.setProperty("SERVER", "192.168.222.128");
propSet.setProperty("INSTANCE", "5151");
propSet.setProperty("DATABASE", "sde");
propSet.setProperty("USER", "sde");
propSet.setProperty("PASSWORD", "sde");
propSet.setProperty("VERSION", "sde.DEFAULT");
IWorkspaceFactory sdeFact = (IWorkspaceFactory)context.createObject(SdeWorkspaceFactory.getClsid());//new SdeWorkspaceFactory();
//IWorkspaceFactory sdeFact = new SdeWorkspaceFactory();
// Open the ArcSDE workspace using the connection PropertySet
IWorkspace ws = sdeFact.open(propSet, 0);
//Workspace ws = new Workspace(sdeFact.open(propSet, 0));
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)ws;
IWorkspaceEdit eWorkspace = (IWorkspaceEdit)ws;
IFeatureDataset featureDataset = featureWorkspace.openFeatureDataset("ZT_HY");   
IWorkspace workspace = featureDataset.getWorkspace();
IFeatureWorkspace fWorkspace = new IFeatureWorkspaceProxy(workspace);          
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值