To operate sde in Java, you must first download the jar packages supported by sde. The jpe92_sdk.jar and jsde92_sdk.jar packages can be found in the installed directory.
To operate sde in Java, you must first download the jar packages supported by sde. The jpe92_sdk.jar and jsde92_sdk.jar packages can be found in the installed directory.
Sde is short for Spatial Database Engine.
SDE is a customer/server software that enables storage, management, and quick query and retrieval of spatial data in industrial standard database management systems. Place GIS data in RDBMS, however, generally RDBMS does not provide the GIS data type (such as the point, line, polygon, And the topological relationship between these feature and projection coordinates ), RDBMS only supports a small amount of data types: int, float, double, Blob, Long, char, etc., usually numbers, strings and binary data. In addition, RDBMS does not extract the storage of GIS data types, nor does it provide operations on these basic types (for example, determining the inclusion relationship, adjacent, intersection, difference, distance, shortest path, etc)
To operate sde in Java, you must first download the jar packages supported by sde. The jpe92_sdk.jar and jsde92_sdk.jar packages can be found in the installed directory.
The following is the link code of the sde obtained by Java:
/**
* Connect to the sde Service
* @ Return
*/
Public SeConnection getConnection (){
SeConnection conn = null;
Try {
Conn = new SeConnection (SDE_SERVER_IP, SDE_PROT, SDE_DATEBASE_SID, SDE_USERNAME, SDE_PASSWORD );
} Catch (SeException e ){
Return null;
}
Return conn;
}
Add sde data and DOT/line
/**
* Adding resource information points to sde
* @ Param pointBean coordinate point POJO
* @ Param tbName layer name
* @ Param String typeName the painting type. It must be 1 point, 2 lines, and 3 sides.
* @ Return Long sde id
* @ Throws Exception
*/
Public Long addPointObject (PointBean pointBean, List columnList, String tableName, String typeName) throws Exception {
SeLayer insertLayer = null;
SeConnection conn = null;
Long intsertRowID = null;
SeInsert insert = null;
Try {
Conn = this. getConnection ();
InsertLayer = new SeLayer (conn, tableName, "SHAPE ");
If (insertLayer = null ){
Throw new Exception ("The Space table cannot be found:" + tableName );
}
Conn. startTransaction ();
Int arrayLength = columnList. size () + 1;
String [] cols = new String [arrayLength];
Cols [0] = "SHAPE ";
For (int I = 0; I ColumnBean columnBean = (ColumnBean) columnList. get (I );
Cols [I + 1] = columnBean. getName ();
}
Insert = new SeInsert (conn );
Insert. into table (insertLayer. getName (), cols );
Insert. setWriteMode (true );
SeCoordinateReference coordref = (SeCoordinateReference) insertLayer. getCoordRef ();
SeShape shape = new SeShape (coordref );
If ("1". equals (typeName )){
This. addPoint (pointBean, shape );
} Else if ("2". equals (typeName )){
This. addLine (pointBean, shape );
} Else if ("3". equals (typeName )){
This. addPolygon (pointBean, shape );
}
SeRow row = insert. getRowToSet ();
Row. setShape (0, shape );
For (int I = 0; I ColumnBean columnBean = (ColumnBean) columnList. get (I );
If (columnBean. getTypeObject () = 1 ){
Row. setNString (I + 1, String. valueOf (columnBean. getValObject ()));
} Else if (columnBean. getTypeObject () = 2 ){
Row. setInteger (I + 1, Integer. parseInt (columnBean. getValObject (). toString ()));
} Else if (columnBean. getTypeObject () = 3 ){
Row. setDouble (I + 1, Double. parseDouble (columnBean. getValObject (). toString ()));
}
}
Insert.exe cute ();
IntsertRowID = new Long (insert. lastInsertedRowId (). longValue ());
Conn. commitTransaction ();
} Catch (Exception ex ){
Ex. printStackTrace ();
Conn. rollbackTransaction ();
} Finally {
If (insert! = Null ){
Insert. close ();
}
If (conn! = Null ){
Conn. close ();
}
}
Return intsertRowID;
}
Sde query interface implementation
/**
* Query sde
* @ Param productId product id
* @ Throws SeException
*/
Public SeQuery searchSde (Long productId, String tableName) throws SeException {
SeConnection conn = getConnection ();
SeLayer layer = new SeLayer (conn, tableName, "SHAPE ");
SeSqlConstruct sqlConstruct = new SeSqlConstruct (layer. getName ());
If (productId! = Null ){
SqlConstruct. setWhere ("yid =" + productId. intValue ());
}
String [] cols = null;
If (tableName. equals ("YU_AN_POINT") | tableName. equals ("FANG_AN_POINT ")){
Cols = new String [4];
Cols [0] = new String ("OBJECTID ");
Cols [1] = layer. getSpatialColumn ();
Cols [2] = new String ("NAME ");
Cols [3] = new String ("IMAGETYPE ");
} Else {
Cols = new String [3];
Cols [0] = new String ("OBJECTID ");
Cols [1] = layer. getSpatialColumn ();
Cols [2] = new String ("NAME ");
}
System. out. println ("cols. length:" + cols. length );
SeQuery query = new SeQuery (conn, cols, sqlConstruct );
Query. prepareQuery ();
Query.exe cute ();
Return query;
}
Delete SDE Information