默认头像
路人甲
路人甲
  • 注册日期2005-11-21
  • 发帖数21
  • QQ
  • 铜币218枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2153回复:5

有人能解决吗

楼主#
更多 发布于:2006-07-31 10:28

现做shape文件入库的时候出现了中文属性字段不能入库的问题,说是不能读取中文字段,有高手知道怎么解决吗,我的设计思路是先在SDE数据库中新建一个FeatureClass,然后将Shape文件中的FeatureClass直接拷贝到数据库中去,因为没有涉及到Field所以没办法将中文字符转化为字节

喜欢0 评分0
默认头像
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2006-07-31 10:36
请你把提示的错误信息贴出来
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
默认头像
路人甲
路人甲
  • 注册日期2005-11-21
  • 发帖数21
  • QQ
  • 铜币218枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2006-07-31 10:52

错误代码是

AutomationException: 0x80041538 - Underlying DBMS error[Microsoft OLE DB Provider for SQL Server: ?÷±í????????±????¨??????±í 'ROAD' ???à?????¨?????? 'FID'??][sde.SDE.road] in 'esriDataSourcesGDB.SdeWorkspace.1'
at com.esri.arcgis.geodatabase.FeatureDataConverter.convertFeatureClass(Unknown Source)
at convertor.SHPToGeo.ConvertFeatureClass(SHPToGeo.java:208)
at convertor.SHPToGeo.saveShap(SHPToGeo.java:87)
at ServiceConnect.ServiceDateWriter.DataSDEIn(ServiceDateWriter.java:193)
at ServiceConnect.ServiceDateWriter.execute(ServiceDateWriter.java:103)
at XPub.executor.ImportToDB.execute(ImportToDB.java:65)
at XPub.Server.handleInformation(Server.java:157)
at com.teamax.xgis.geotools.xgisNIOServer$ThreadHandler.loadInformation(xgisNIOServer.java:454)
at com.teamax.xgis.geotools.xgisNIOServer$ThreadHandler.handleBuffer(xgisNIOServer.java:392)
at com.teamax.xgis.geotools.xgisNIOServer$ThreadHandler.run(xgisNIOServer.java:343)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

举报 回复(0) 喜欢(0)     评分
默认头像
路人甲
路人甲
  • 注册日期2005-11-21
  • 发帖数21
  • QQ
  • 铜币218枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-07-31 10:53

原码是

import java.io.IOException;
import java.net.UnknownHostException;

import java.util.Date;
import java.util.Vector;

import com.esri.arcgis.datasourcesGDB.AccessWorkspaceFactory;
import com.esri.arcgis.datasourcesGDB.SdeWorkspaceFactory;
import com.esri.arcgis.datasourcesfile.ShapefileWorkspaceFactory;
import com.esri.arcgis.geodatabase.*;
import com.esri.arcgis.system.AoInitialize;
import com.esri.arcgis.system.EngineInitializer;
import com.esri.arcgis.system.IClone;
import com.esri.arcgis.system.ICloneProxy;
import com.esri.arcgis.system.IName;
import com.esri.arcgis.system.INameProxy;
import com.esri.arcgis.system.IPropertySet;
import com.esri.arcgis.system.PropertySet;
import com.esri.arcgis.system.esriLicenseProductCode;

public class SHPToGeo {
AoInitialize aoInit=null;
IFeatureWorkspace ws;
private IFeatureClass annoFClass = null;
private    String                     _instance          =           "5151/tcp";
private   IFeatureClassName          _pInFCName         =           null;
private    String                    _sOutFCName        =           null;
private   IPropertySet                pPropSet          =           null;
private   IWorkspaceName              pOutWsName        =           null;
private    Vector                      data             =            new Vector();
private    String                      layname          =           null;
public static void main(String []arg)
{

 Date d = new Date();
 System.out.println(d.getHours()+"   "+d.getMinutes()+"  "+d.getSeconds());
// new SHPToGeo();
}
public SHPToGeo(String server,String datebaseN,String user,String password,String layname)
{
 this.layname = layname;
 try
 {
  EngineInitializer.initializeVisualBeans();
  aoInit = new AoInitialize();
  aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);
 // ICommandHostPtr pICommandHost(__uuidof(CommandHost));
   pPropSet = new PropertySet();
  IWorkspaceFactory pSdeFact = new SdeWorkspaceFactory();
  pPropSet.setProperty( "SERVER", server);
  pPropSet.setProperty( "INSTANCE", "5151/tcp");
  pPropSet.setProperty( "DATABASE", datebaseN);
  pPropSet.setProperty( "USER", user);
  pPropSet.setProperty( "PASSWORD", password);
  pPropSet.setProperty( "version", "sde.default");

 
 }
 catch( IOException e)
 {
  e.printStackTrace();
 }

}
public void saveShap()
{
 getInConvert();
 ggg();
 ConvertFeatureClass(_pInFCName, pOutWsName, null, _sOutFCName);
}
public void getInConvert()
{

 Vector v = new Vector();
 try {
  pOutWsName =new WorkspaceName();

  pOutWsName.setWorkspaceFactoryProgID("esriDataSourcesGDB.SDEWorkspaceFactory");
  pOutWsName.setConnectionProperties(pPropSet);

  _pInFCName = new FeatureClassName();
 
  IDatasetName pDatasetName ;
  pDatasetName = (IDatasetName)_pInFCName;
  pDatasetName.setName(layname);
  pDatasetName.setWorkspaceNameByRef(pOutWsName);
  _sOutFCName = pDatasetName.getName();  
 // IDatasetName pDatasetName1 = (IDatasetName)_pInFCName;

 } catch (UnknownHostException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 } catch (IOException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 }
}

public void ggg()
{
 
 try {
    IWorkspaceName              pINWsName        =           null;
  IDatasetName pInDatasetName     ;
  pINWsName = new WorkspaceName();
  pINWsName.setPathName("D:\\DownLoads\\");
  pINWsName.setWorkspaceFactoryProgID("esriCore.ShapefileWorkspaceFactory.1");
  _pInFCName = new FeatureClassName();
         pInDatasetName = (IDatasetName)_pInFCName;
        pInDatasetName.setName(layname);
         pInDatasetName.setWorkspaceNameByRef(pINWsName) ;
 } catch (UnknownHostException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 } catch (IOException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 }

}
public void ConvertFeatureClass(IFeatureClassName pInFCName,IWorkspaceName pOutWorkspaceName     ,IFeatureDatasetName pOutFDName ,String strOutFCName)
{
  //' Set Output feature class name
 FeatureClassName pOutFCName ;
 try {
  pOutFCName = new FeatureClassName();  
  IDatasetName  pDatasetName;
  pDatasetName = (IDatasetName)pOutFCName;
  pDatasetName.setName(strOutFCName);
  pDatasetName.setWorkspaceNameByRef(pOutWorkspaceName);
   
  if (pOutFDName!=null)
  {
   pOutFCName.setFeatureDatasetNameByRef(null);
  }      
 //   ' Get the fields for the input feature class
 //   ' and run them through the field checker
 //   ' Strip field names which are qualified as Owner.TableName.FieldName
 //   ' this will avoid breaking the field name width limit
  IFields pFields;
  IFields []pOutFields = null;
  IFeatureClass pInFeatureClass = null;
  IName pName ;
  pName=(IName)pInFCName;
  pInFeatureClass =new IFeatureClassProxy( pName.open());
 // pInFeatureClass.addField(fj);
  IClone pSource ;
  pSource = new ICloneProxy(pInFeatureClass.getFields());
  pFields = new IFieldsProxy(pSource.esri_clone());
 
 //
  ISQLSyntax pSQLSyntax;
  pDatasetName = (IDatasetName)pInFCName;
  pName =new INameProxy( pDatasetName.getWorkspaceName());
  pSQLSyntax =new ISQLSyntaxProxy( pName.open());  //'Inline QI on Workspace object
 //  
  int i;
  IField pField ;
  IFieldEdit pFieldEdit;
  String []sStrippedName=null;
  String []sDbName=null;String []sOwnerName=new String[1]; String []sTableName=null ;
 //  
 ////   ' For each field, strip the name
 ////   ' The check on Owner name avoids processing the Shape.Area and Shape.Len fields.
 ////   ' (these are handled by the feature data converter).
  for ( i = 0;i   {
   pField = pFields.getField(i);
      sOwnerName[0] ="" ;
      pSQLSyntax.parseColumnName(pField.getName(), sDbName, sOwnerName, sTableName, sStrippedName);
      if (sOwnerName.length > 0)
      {
       pFieldEdit =new IFieldEditProxy( pField);
       pFieldEdit.setName(pField.getName()) ;
      }
    }
//
//  pSQLSyntax.parseColumnName(fj.getName(), sDbName, sOwnerName, sTableName, sStrippedName);
 //  
  IEnumFieldError[] pEnumFieldError = null;
  IFieldChecker pFieldChecker;
  pFieldChecker = new FieldChecker();
  pFieldChecker.validate(pFields, pEnumFieldError, pOutFields) ;
 //  
  IFeatureDataConverter pFeatureDataConverter ;
  pFeatureDataConverter = new FeatureDataConverter();
 //  
 //   //' Do the conversion
  IEnumInvalidObject pEnumInvalidObject;
  pEnumInvalidObject = pFeatureDataConverter.convertFeatureClass(pInFCName,null,pOutFDName,pOutFCName,null,null,"",1000,0);
 pOutWsName = null;
  pOutWsName = null;
  _sOutFCName = null;
 } catch (UnknownHostException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 } catch (IOException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 }
 }


}

举报 回复(0) 喜欢(0)     评分
默认头像
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
4楼#
发布于:2006-07-31 11:38

你使用的接口应该是支持中文编码的;

可能和你数据库不支持中文编码有关,你可以查询相关资料对数据库进行设置;

GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
默认头像
路人甲
路人甲
  • 注册日期2005-11-21
  • 发帖数21
  • QQ
  • 铜币218枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2006-07-31 13:38

可是我用ArcCatolog直接导SHAPE文件是可以入库的

举报 回复(0) 喜欢(0)     评分
默认头像

返回顶部