try{
// conn.startTransaction();//本例中只有一个点,有没有事务处理无所谓。
String[] cols = new String[3];//这里定义,一定要注意对于objectid是由系统自动维护,如果这个定义中包含了objectid的信息,那么后面无论怎么给值,系统都会出现-113或-114这样的异常。
//String[] cols = new String[1];
cols[0] = new String("人员");
//cols[0] = new String("ss");
cols[1] = new String("罚金");
cols[2] = insertLayer.getSpatialColumn();
//cols[0] = insertLayer.getSpatialColumn();
insert = new SeInsert(conn);
insert.setState(stateOne.getId(), new SeObjectId(SeState.SE_NULL_STATE_ID), SeState.SE_STATE_DIFF_NOCHECK);
insert.intoTable(insertLayer.getName(),cols);
insert.setWriteMode(true);
SeCoordinateReference coordref =(SeCoordinateReference)insertLayer.getCoordRef();
SeShape shape = new SeShape(coordref);
int numParts = 1;
int[] partOffsets = new int[numParts];
partOffsets[0] = 0;
int numPts = 5;
SDEPoint[] ptArray = new SDEPoint[numPts];
// Points of a sub-part should be ordered in the counter-clockwise direction.
ptArray[0] = new SDEPoint(116,36.5);
ptArray[1] = new SDEPoint(116,37);
ptArray[2] = new SDEPoint(116,37.5);
ptArray[3] = new SDEPoint(117,35);
// The last point should be the same as the first. This closes the polygon shape.
ptArray[4] = new SDEPoint(116,36.5);
SeShape shape2 = new SeShape(coordref);
shape2.generatePolygon(numPts, numParts, partOffsets, ptArray);
/* int numPts = 1;
SDEPoint[] ptArray = new SDEPoint[numPts];
ptArray[0] = new SDEPoint(117,36);
shape.generatePoint(numPts, ptArray);*/
SeRow row = insert.getRowToSet();
row.setNString(0, new String("n"));
row.setInteger(1, new Integer(33));
row.setShape(2,shape2);
// row.setShape(0,shape);
insert.execute();
//conn.commitTransaction();
insert.close();
}catch(Exception ex){
ex.printStackTrace();
try {
conn.rollbackTransaction();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ex.printStackTrace();
}finally{
if(insert!=null){
try {
// insert.setWriteMode(false);
insert.close();
} catch (SeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(conn!=null){
try {
conn.close();
} catch (SeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
上边程序正常执行完,没报错,但是登陆数据看看表里 没有数据插入