In one job, there was a need for Java backend to query the Oracle database space data used in ArcGIS, because the first contact with ArcGIS spatial data was only to know that Oracle was able to use st_geometry field storage, such as
However, the query will find that the St_geometry field will appear in the results of a number of sub-fields, for ArcGIS geography knowledge very little, do not know how to query a single coordinate how to get, some friends said that need to configure the listening file.
Anyway, at least take a look at a Daniel article, http://blog.csdn.net/linghe301/article/details/8058806 based on the ArcSDE for Java API, can be added to the deletion of the operation.
For the introduction of ARCSDE for Java, please refer to the article, do not write repeatedly. The following demo sample code, modified, added some gaze, or good
First, the Jsde_sdk.jar,Jpe_sdk.jar,Concurrent.jar,icu4j_3_2.jar package download down into the javaproject can be. The following are examples of four jar packages:
http://download.csdn.net/detail/xiaokui_wingfly/8032329
The constant meaning and method that are useful in detail in the query is explained by the examiner's API: http://help.arcgis.com/en/geodatabase/10.0/sdk/arcsde/api/japi/docs/index.html
Package Cn.sde.test;import Java.text.simpledateformat;import Java.util.date;import Com.esri.sde.sdk.client.sdepoint;import Com.esri.sde.sdk.client.secolumndefinition;import Com.esri.sde.sdk.client.seconnection;import Com.esri.sde.sdk.client.secoordinatereference;import Com.esri.sde.sdk.client.seexception;import Com.esri.sde.sdk.client.sefilter;import Com.esri.sde.sdk.client.seinstance;import Com.esri.sde.sdk.client.selayer;import Com.esri.sde.sdk.client.SeQuery ; Import Com.esri.sde.sdk.client.sequeryinfo;import Com.esri.sde.sdk.client.serelease;import Com.esri.sde.sdk.client.serow;import Com.esri.sde.sdk.client.seshape;import Com.esri.sde.sdk.client.seshapefilter;import Com.esri.sde.sdk.client.sesqlconstruct;import Com.esri.sde.sdk.client.setable;public class T {private static Seconnection conn = null;private static String Server = "17 2.25.0.253 "; SDE Server private static String instance = "5151"; SDE Port private static String database = "ORCL"; SDE database private static String username ="SDE"; SDE User name private static String password = "SDE"; SDE Password//Get ARCSDE connection private static Seconnection Getconn () {if (conn = = null) {try {conn = new Seconnection (server, Instan CE, database, username, password);} catch (Seexception ex) {ex.printstacktrace ();}} Return conn;} /** * ARCSDE management */public static void Getarcsdeinfo () {try {seinstance instance = new Seinstance (server, "5151"); Seinstance.seinstancestatus status = Instance.getstatus (); System.out.println ("Number of connections:" + status.getnumconnections ()); System.out.println ("Able to connect:" + status.isaccepting ()); System.out.println ("------------------------------------------------"); seinstance.seinstanceconfiguration config = instance.getconfiguration (); SYSTEM.OUT.PRINTLN ("Maximum number of connections:" + config.getmaxconnections ()); System.out.println ("------------------------------------------------"); seinstance.seinstancestats[] stats = instance.getstats (); for (int i = 0; i < stats.length; i++) {System.out.println ("action Number: "+ stats[i].getoperationcount ());} System.out.println ("------------------------------------------------"); seinstance.seinstanceusers[] users = instance.getusers (); for (int j = 0; J < Users.length; J + +) {System.out.println ("user Name: "+ users[j].getusername ()); SYSTEM.OUT.PRINTLN ("System name:" + users[j].getsysname ()); SYSTEM.OUT.PRINTLN ("Server start time:" + users[j].getserverstarttime ()); SYSTEM.OUT.PRINTLN ("Server pid:" + users[j].getserverpid ()); System.out.println ("*****************************");} System.out.println ("------------------------------------------------"); SYSTEM.OUT.PRINTLN ("System name:" + instance.getservername ()); System.out.println ("------------------------------------------------"); System.out.println ("------------------------------------------------"); seinstance.seinstancetablelocks[] Tablelocks = Instance.gettablelocks (); for (int i = 0; i < tablelocks.length; i++) {Sy STEM.OUT.PRINTLN ("Table level lock Type:" + tablelocks[i].getlocktype ()); SYSTEM.OUT.PRINTLN ("Table level lock PID:" + tablelocks[i].getpid ()); SYSTEM.OUT.PRINTLN ("Table level Lock Register ID:" + tablelocks[i].getregistrationid ()); SyStem.out.println ("*****************************");} System.out.println ("------------------------------------------------");} catch (Seexception e) {e.printstacktrace ();}} /** * Spatial condition query x, y coordinate parameter value */public static void Spatialquery_hz (double X, double y) {try {SimpleDateFormat formatter = new Sim Pledateformat ("Yyyy-mm-dd HH:mm:ss ss"); Long startTime = System.currenttimemillis ();D ate startdate = new Date (startTime ); System.out.println ("Start time:" + Formatter.format (startdate)); String tbname = "Ezgisdata. DCQWG_HB "; string[] cols = new String[7];cols[0] = "Jdname"; cols[1] = "Jdcode"; cols[2] = "Sqname"; cols[3] = "Sqcode"; cols[4] = "Wgnam E "; cols[5] =" Wgcode "; cols[6] =" TYPE "; Seconnection conn = Getconn (); Selayer layer = new Selayer (conn, tbname, "SHAPE"); secoordinatereference CR = Layer.getcoordref (); Sefilter[] Filters = new SEFILTER[1]; Seshape shape = new Seshape (CR); Sdepoint pt = new Sdepoint (x, y), Shape.generatepoint (1, new sdepoint[] {pt});//Method_et_or_ai, Method_et_or_ii, METHOD _ii_or_et, MEthod_ai,//Method_ii, Method_ai_no_et, method_ii_no_et,//method_pc, method_pc_no_et, METHOD_PIP,SeFilter filter = new Seshapefilter (Tbname, Layer.getspatialcolumn (), shape, SESHAPEFILTER.METHOD_PIP); filters[0] = filter; Sesqlconstruct sqlcons = new Sesqlconstruct (tbname); Sequery query = new Sequery (conn, cols, sqlcons); Query.preparequery (); Query.setspatialconstraints (Sequery.se_ Attribute_first, False, filters); Query.execute (); Serow row = Query.fetch (); while (row! = null) {System.out.println (row.getobject (0). toString () + "," + row.getobject (2). To String () + "," + row.getobject (3). ToString () + "," + row.getobject (6). ToString ()); row = Query.fetch ();} Long endTime = System.currenttimemillis ();D ate endDate = new Date (endTime); System.out.println ("End time:" + Formatter.format (endDate)); System.out.println ("Difference:" + ((endtime-starttime)/1000) + "SEC \ n");} catch (Exception ex) {ex.printstacktrace ();}} /** * Normal query */public static void Commonquery () {try {seconnection conn = Getconn (); setable table = New Setable (conn, "Ezgisdata. Dcqwg_py "); secolumndefinition[] TableDef = Table.describe (); string[] cols = new String[tabledef.length];for (int j = 0; J < Cols.length; J + +) {Cols[j] = Tabledef[j].getname ();} Sesqlconstruct sqlcons = new Sesqlconstruct ("Ezgisdata. Dcqwg_py "); Sequery query = new Sequery (conn, cols, sqlcons); Sequeryinfo queryinfo = new Sequeryinfo (); Queryinfo.setquerytype (Sequeryinfo.se_querytype_attribute_first); Queryinfo.setcolumns (cols); queryinfo.setconstruct (sqlcons); Query.preparequeryinfo (QueryInfo); Query.execute (); Serow row = Query.fetch (); while (row! = null) {System.out.println (row.getobject (0). toString () + ":" + row.getobject (1). t Ostring () + ":" + row.getobject (3). ToString () + ":" + row.getobject (4). ToString () + ":" + row.getobject (5). ToString () + ":" + row.getobject (6). ToString () + ":" + row.getobject (7). ToString () + ":" + row.getobject (8). ToString ()); row = Query.fetch ();}} catch (Exception ex) {ex.printstacktrace ();}} /** * Attribute condition query */public static VoiD attributequery () {try {String tbname = "Ezgisdata. Dcqwg_py "; string[] cols = new String[4];cols[0] = "NEWSQMC"; cols[1] = "NEWSQBM"; cols[2] = "NEWWGMC"; cols[3] = "NEWWGBM"; Seconnection conn = Getconn (); Sesqlconstruct sqlcons = new Sesqlconstruct (tbname); Sqlcons.setwhere ("Jdname= ' Li Ping"); Sequery query = new Sequery (conn, cols, sqlcons); Query.preparequery (cols, sqlcons); Query.execute (); Serow row = Query.fetch (); int reccount = 0;while (row! = null) {RecCount = RecCount + 1; System.out.println (integer.tostring (RecCount) + ":" + row.getobject (0). ToString () + ":" + row.getobject (1). ToString () + ":" + row.getobject (2). ToString () + ":" + row.getobject (3). ToString ()); row = Query.fetch ();}} catch (Exception ex) {ex.printstacktrace ();}} /** * Get ARCSDE version number information */public static void GetVersion () {Seconnection conn = Getconn (); Serelease release = Conn.getrelease (); System.out.println (Release.getbugfix ()); System.out.println (Release.getdesc ()); System.out.println (Release.getrelease ()); System.out.println(Release.getmajor ()); System.out.println (Release.getminor ());} public static void Main (string[] args) {getarcsdeinfo (); Commonquery (); Attributequery (); GetVersion (); Spatialquery_hz (506019.02883, 302758.03546);}}
Result: Too much print content, omit the content xxxx word
------------------------------------------------
Table level lock pid:526084
Table Level Lock Register id:1966
*****************************
....
1:jdname: East Flower Market: Jdcode:13:sqname: Faithful Community: Sqcode:1303:wgname: Faithful Community No. 3rd grid: WGCODE:13033-0152:TYPE:SG
.....
ArcSDE SDK for Java Two development introduction, demo sample