Acrsde development instance using Java [reprint]

Source: Internet
Author: User
Acrsde development instance using Java [reprint]Http://www.gispark.com/html/GIS-Spatial-Database/2007/1227/2002.html

 

An acrsde development instance using Java: ArcSDE provides two interfaces: c api and Java API. Here we will only introduce how to develop ArcSDE through Java APIs.
Development Environment:
JDK 1.5
Win plug P
Eclipse 3.1 + myeclipse
ArcSDE for Oracle 9i
(1) Export the Three jar packages required by ArcSDE Java APIs to the web \ lib directory, including jsde90_sdk.jar, jpe90_sdk.jar, and concurrent. jar;
(2) Add a vertex:
Public class addpointbean {
Public static Boolean Process (httpservletrequest request,
Httpservletresponse response) throws exception {
Map map = NULL;
If (request. getsession (). getattribute (staticconstant. session_map) = NULL ){
String strerr = "map not initialized ";
Request. setattribute (staticconstant. request_error, strerr); string 3
Return false;
}
Map = (MAP) request. getsession (). getattribute (staticconstant. session_map );
// Connect to SDE
Seconnection conn = NULL;
String Server = "menglikunm ";
Int instance = 5151;
String database = "ora ";
String user = "SDE ";
String Password = "SDE ";
Selayer insertlayer = NULL;
Try {
Conn = new seconnection (server, instance, database, user, password );

String 1

Vector layerlist = conn. getlayers ();
For (INT Index = 0; index <layerlist. Size (); index ++ ){
Selayer layer = (selayer) layerlist. elementat (INDEX );
// Displays the layer's name
System. Out. println (layer. getname ());
// Displays the layer's ID
System. Out. println (layer. GETID (). longvalue ());
// Displays the layer's spatial column name

String 7

System. Out. println (layer. getspatialcolumn ());
If (layer. getname (). inclusignorecase ("zhengfujitsu iguan ")){
Insertlayer = layer;
}
}
} Catch (seexception e ){
E. printstacktrace ();
Return false;
}
// Start data insertion
Try {string 6
Conn. starttransaction ();
String [] Cols = new string [2];
Cols [0] = new string ("name ");
Cols [1] = insertlayer. getspatialcolumn ();
Seinsert insert = new seinsert (conn );
Insert. into table (insertlayer. getname (), cols );
Insert. setwritemode (true );
Secoordinatereference coordref = (secoordinatereference) insertlayer. getcoordref ();
Seshape shape = new seshape (coordref );
Double X = map. tomappoint (10, 10). getx ();

String 9

Double Y = map. tomappoint (10, 10). Gety ();

Int numpts = 1;
Sdepoint [] ptarray = new sdepoint [numpts];
Ptarray [0] = new sdepoint (x, y );
Shape. generatepoint (numpts, ptarray );

Serow ROW = insert. getrowtoset ();
Row. setstring (0, "Quiz point ");
Row. setshape (1, shape );
Insert.exe cute (); string 7
Insert. Close ();
Conn. committransaction ();
Conn. Close ();
} Catch (exception ex ){
Conn. rollbacktransaction ();
Conn. Close ();
Ex. printstacktrace ();
}
Return true;
}
} (3) Deletion Point:
Public class deletepointbean {
Public static Boolean Process (httpservletrequest request,
Httpservletresponse response) throws exception {
// Connect to SDE

String 5

Seconnection conn = NULL;
String Server = "menglikunm ";
Int instance = 5151;
String database = "ora ";
String user = "SDE ";
String Password = "SDE ";
Try {
Conn = new seconnection (server, instance, database, user, password );
Vector layerlist = conn. getlayers ();
For (INT Index = 0; index <layerlist. Size (); index ++ ){
Selayer layer = (selayer) layerlist. elementat (INDEX); string 5
// Displays the layer's name
System. Out. println (layer. getname ());
// Displays the layer's ID
System. Out. println (layer. GETID (). longvalue ());
// Displays the layer's spatial column name
System. Out. println (layer. getspatialcolumn ());
}
} Catch (seexception e ){
E. printstacktrace ();

String 8

Return false;
}
// Start to delete data
Try {
Conn. starttransaction ();
Sedelete delete = new sedelete (conn );
Seobjectid id = new seobjectid (641 );
Delete. byid ("zhengfujiguan", ID );
Conn. committransaction ();
Delete. Close ();
} Catch (exception ex ){
Conn. rollbacktransaction (); string 4
Conn. Close ();
Ex. printstacktrace ();
}
Return true;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.