queryfromtable.java.svn-base

来自「aresde 空间数据开发 例子」· SVN-BASE 代码 · 共 65 行

SVN-BASE
65
字号
import java.io.IOException;

import com.esri.arcgis.datasourcesGDB.SdeWorkspaceFactory;
import com.esri.arcgis.geodatabase.ICursor;
import com.esri.arcgis.geodatabase.IFeatureWorkspace;
import com.esri.arcgis.geodatabase.IQueryFilter;
import com.esri.arcgis.geodatabase.IRow;
import com.esri.arcgis.geodatabase.QueryFilter;
import com.esri.arcgis.geodatabase.Table;
import com.esri.arcgis.system.AoInitialize;
import com.esri.arcgis.system.EngineInitializer;
import com.esri.arcgis.system.PropertySet;
import com.esri.arcgis.system.esriLicenseProductCode;


public class QueryfromTable {
	
	public static void query() throws Exception{
		com.esri.arcgis.system.PropertySet propSet = new PropertySet();
		
		//连接参数
		propSet.setProperty("SERVER", "192.168.1.220");
		propSet.setProperty("INSTANCE", "5151");
		//propSet.setProperty("DATABASE", "sde");
		propSet.setProperty("USER", "sde");
		propSet.setProperty("PASSWORD", "sde");
		propSet.setProperty("VERSION", "SDE.DEFAULT");
		
		SdeWorkspaceFactory swf=new SdeWorkspaceFactory();
		
		//连接SDE
		IFeatureWorkspace ifw=(IFeatureWorkspace)swf.open(propSet, 0);
		
		Table table= new Table(ifw.openTable("RELATION"));
		
		IQueryFilter q= new QueryFilter();
		q.setWhereClause("tocimid = '230000701' and fromlayer = 'SDE.S210000070_Breaker_Layer'");
		ICursor cursor=table.ITable_search(q, false);
		
		IRow r=cursor.nextRow();
		System.out.println("...");
		while(r!=null){
			System.out.println(r.getValue(cursor.findField("tocimid")));
			r=cursor.nextRow();
		}
	}
	
	
	public static void main(String[] args) throws IOException{
		EngineInitializer.initializeEngine();
		final AoInitialize aoInit =new AoInitialize();
		try{
			aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);
			
			query();
			
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			aoInit.shutdown();
		}
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?