arcSDE插入空间数据时出现错误SPECIFIED ATTRIBUTE COLUMN DOESN'T EXIST的原因和解决办法

当我们用下面的通用代码插入一个点到空间表中时,会报SPECIFIED ATTRIBUTE COLUMN DOESN'T EXIST错误,错误信息如下:
ArcSDE Error Number        : -38
 Error Description          : SPECIFIED ATTRIBUTE COLUMN DOESN'T EXIST.
com.esri.sde.sdk.client .SeException:
 at com.esri.sde.sdk.client.j.a(Unknown Source)
 at com.esri.sde.sdk.client.j.a (Unknown Source)
 at com.esri.sde.sdk.client .SeInsert.intoTable(Unknown Source)
 at com.suzhou.service.sde.SDEOpera tion.addPointObject(SDEOperation.java:59)
 at com.suzhou.struts.action .AdminCheckNewObjAction.execute (AdminCheckNewObjAction.java:143)
 at org.springframework.web.struts .DelegatingActionProxy.execute(DelegatingActionProxy.java:106)
 at org.apache.struts.action .RequestProcessor.processAction Perform(RequestProcessor.java :419)
 at org.apache.struts.action .RequestProcessor.process(RequestProcessor.java:224)
 at org.apache.struts.action .ActionServlet.process(ActionServlet.java:1194)
 at org.apache.struts.action .ActionServlet.doGet ( ActionServlet.java:414)
 at javax.servlet.http.HttpServlet .service(HttpServlet.java:689)
 at javax.servlet.http.HttpServlet .service(HttpServlet.java:802)
 at org.apache.catalina.core .ApplicationFilterChain .internalDoFilter (ApplicationFilterChain.java:237)
 at org.apache.catalina.core .ApplicationFilterChain .doFilter(ApplicationFilterChain.java:157)
 at com.suzhou.util.SetCharacterEnc odingFilter.doFilter(SetCharacterEncodingFilter.java :24)
 at org.apache.catalina.core .ApplicationFilterChain .internalDoFilter(ApplicationFilterChain.java:186)
 at org.apache.catalina.core .ApplicationFilterChain .doFilter(ApplicationFilterChain.java:157)
 at org.apache.catalina.core .StandardWrapperValve.invoke (StandardWrapperValve.java:214)
 at org.apache.catalina.core .StandardValveContext.invokeNex t(StandardValveContext.java:104)
 at org.apache.catalina.core .StandardPipeline.invoke(StandardPipeline.java:520)
 at org.apache.catalina.core .StandardContextValve.invokeInt ernal (StandardContextValve.java:198)
 at org.apache.catalina.core .StandardContextValve.invoke(StandardContextValve.java:152)
 at org.apache.catalina.core .StandardValveContext.invokeNex t(StandardValveContext.java:104)
 at org.apache.catalina.core .StandardPipeline.invoke(StandardPipeline.java:520)
 at org.apache.catalina.core .StandardHostValve.invoke(StandardHostValve.java:137)
 at org.apache.catalina.core .StandardValveContext.invokeNex t (StandardValveContext.java:104)
 at org.apache.catalina.valves .ErrorReportValve.invoke(ErrorReportValve.java:118)
 at org.apache.catalina.core .StandardValveContext.invokeNex t(StandardValveContext.java:102)
 at org.apache.catalina.core .StandardPipeline.invoke (StandardPipeline.java:520)
 at org.apache.catalina.core .StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.core .StandardValveContext.invokeNex t(StandardValveContext.java:104)
 at org.apache.catalina.core .StandardPipeline.invoke (StandardPipeline.java:520)
 at org.apache.catalina.core .ContainerBase.invoke(ContainerBase.java:929)
 at org.apache.coyote.tomcat5 .CoyoteAdapter.service(CoyoteAdapter.java:160)
 at org.apache.coyote.http11 .Http11Processor.process (Http11Processor.java:799)
 at org.apache.coyote.http11 .Http11Protocol$Http11Connectio nHandler.processConnection(Http11Protocol.java:705)
 at org.apache.tomcat.util.net .TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
 at org.apache.tomcat.util.threads .ThreadPool$ControlRunnable.run(ThreadPool.java:683)
 at java.lang.Thread.run(Thread.java:619)
插入点的java代码如下:

String server = "menglikunm";

 int instance = 5151;

 String database = "ora";

 String user = "suzhou";

 String password = "suzhou";

 public Long addPointObject(long x, long y, String tabname) throws Exception {
  SeLayer insertLayer = null;
  SeConnection conn = null;
  Long intsertRowID = null;
  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);
    System.out.println(layer.getName());
    if ( layer.getName().equalsIgnoreCase(tabname)) {
     insertLayer = layer;
     break;
    }
   }
  } catch (SeException e) {
   // e.printStackTrace();
   throw e;
  }
  // 开始插入数据
  if (insertLayer == null) {
   throw new Exception("找不到空间表:" + tabname);
  }
  try {
   conn.startTransaction();
   String[] cols = new String[1];
   //cols[0] = insertLayer.getSpatialColumn();
   cols[0]="SHAPE";
   System.out.println(cols[0]);
   SeInsert insert = new SeInsert(conn);
   System.out.println(insertLayer.getName());
   insert.intoTable(insertLayer.getName(), cols);//运行到这里时出现错误!
   insert.setWriteMode(true);
   SeCoordinateReference coordref = (SeCoordinateReference) insertLayer
     .getCoordRef();
   SeShape shape = new SeShape(coordref);

   int numPts = 1;
   SDEPoint[] ptArray = new SDEPoint[numPts];
   ptArray[0] = new SDEPoint(x, y);
   shape.generatePoint(numPts, ptArray);
   SeRow row = insert.getRowToSet();
   row.setShape(0, shape);
   insert.execute();
   intsertRowID = new Long(insert.lastInsertedRowId().longValue());
   insert.close();
   conn.commitTransaction();
   conn.close();
  } catch (Exception ex) {
   ex.printStackTrace ();
   try {
    conn.rollbackTransaction();
    conn.close();
   } catch (Exception ex2) {
   }
   throw ex;
  }
  return intsertRowID;
 }

之所以出现这个错误,是因为当插入一个点到空间表中时,arcsde自动生成一个OBJECTID值,但如果你的空间表导到SDE的时候表中已经有了OBJECTID字段,SDE自动生成的是OBJECTID_1字段作为每条记录的ID字段,如果你把OBJECTID_1字段人为的删除,那么这时候arcSDE就找不到该字段了,就会报出SPECIFIED ATTRIBUTE COLUMN DOESN'T EXIST.的错误,解决办法是重新导一下该空间表,且导入的时候不能有命名为OBJECTID的字段。

很多时候,这些问题都要你自己来发现和解决,不能太相信ESRI的技术支持,他们大部分时候都不能给你什么帮助:)

你可能感兴趣的:(arcSDE插入空间数据时出现错误SPECIFIED ATTRIBUTE COLUMN DOESN'T EXIST的原因和解决办法)