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

有人能解决吗

楼主#
更多 发布于:2006-07-31 10:28
<P>现做shape文件入库的时候出现了中文属性字段不能入库的问题,说是不能读取中文字段,有高手知道怎么解决吗,我的设计思路是先在SDE数据库中新建一个FeatureClass,然后将Shape文件中的FeatureClass直接拷贝到数据库中去,因为没有涉及到Field所以没办法将中文字符转化为字节</P>
喜欢0 评分0
benlb
路人甲
路人甲
  • 注册日期2005-11-21
  • 发帖数21
  • QQ
  • 铜币218枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-07-31 13:38
<P>可是我用ArcCatolog直接导SHAPE文件是可以入库的</P>
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
2楼#
发布于:2006-07-31 11:38
<P>你使用的接口应该是支持中文编码的;</P>
<P>可能和你数据库不支持中文编码有关,你可以查询相关资料对数据库进行设置;</P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
benlb
路人甲
路人甲
  • 注册日期2005-11-21
  • 发帖数21
  • QQ
  • 铜币218枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-07-31 10:53
<P>原码是</P>

<P>import java.io.IOException;<BR>import java.net.UnknownHostException;</P>
<P>import java.util.Date;<BR>import java.util.Vector;</P>
<P>import com.esri.arcgis.datasourcesGDB.AccessWorkspaceFactory;<BR>import com.esri.arcgis.datasourcesGDB.SdeWorkspaceFactory;<BR>import com.esri.arcgis.datasourcesfile.ShapefileWorkspaceFactory;<BR>import com.esri.arcgis.geodatabase.*;<BR>import com.esri.arcgis.system.AoInitialize;<BR>import com.esri.arcgis.system.EngineInitializer;<BR>import com.esri.arcgis.system.IClone;<BR>import com.esri.arcgis.system.ICloneProxy;<BR>import com.esri.arcgis.system.IName;<BR>import com.esri.arcgis.system.INameProxy;<BR>import com.esri.arcgis.system.IPropertySet;<BR>import com.esri.arcgis.system.PropertySet;<BR>import com.esri.arcgis.system.esriLicenseProductCode;</P>
<P>public class SHPToGeo {<BR> AoInitialize aoInit=null;<BR> IFeatureWorkspace ws;<BR> private IFeatureClass annoFClass = null;<BR> private    String                     _instance          =           "5151/tcp";<BR> private   IFeatureClassName          _pInFCName         =           null;<BR> private    String                    _sOutFCName        =           null;<BR> private   IPropertySet                pPropSet          =           null; <BR> private   IWorkspaceName              pOutWsName        =           null;<BR> private    Vector                      data             =            new Vector();<BR> private    String                      layname          =           null;<BR> public static void main(String []arg)<BR> {</P>
<P>  Date d = new Date();<BR>  System.out.println(d.getHours()+"   "+d.getMinutes()+"  "+d.getSeconds());<BR> // new SHPToGeo();<BR> }<BR> public SHPToGeo(String server,String datebaseN,String user,String password,String layname)<BR> {<BR>  this.layname = layname;<BR>  try<BR>  {<BR>   EngineInitializer.initializeVisualBeans();<BR>   aoInit = new AoInitialize();<BR>   aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);<BR>  // ICommandHostPtr pICommandHost(__uuidof(CommandHost));<BR>    pPropSet = new PropertySet();<BR>   IWorkspaceFactory pSdeFact = new SdeWorkspaceFactory();<BR>   pPropSet.setProperty( "SERVER", server);<BR>   pPropSet.setProperty( "INSTANCE", "5151/tcp");<BR>   pPropSet.setProperty( "DATABASE", datebaseN);<BR>   pPropSet.setProperty( "USER", user);<BR>   pPropSet.setProperty( "PASSWORD", password);<BR>   pPropSet.setProperty( "version", "sde.default");</P>
<P>   <BR>  }<BR>  catch( IOException e)<BR>  {<BR>   e.printStackTrace();<BR>  }</P>
<P> }<BR> public void saveShap()<BR> {<BR>  getInConvert();<BR>  ggg();<BR>  ConvertFeatureClass(_pInFCName, pOutWsName, null, _sOutFCName);<BR> }<BR> public void getInConvert()<BR> {<BR> <BR>  Vector v = new Vector();<BR>  try {<BR>   pOutWsName =new WorkspaceName();</P>
<P>   pOutWsName.setWorkspaceFactoryProgID("esriDataSourcesGDB.SDEWorkspaceFactory");<BR>   pOutWsName.setConnectionProperties(pPropSet);</P>
<P>   _pInFCName = new FeatureClassName();<BR>   <BR>   IDatasetName pDatasetName ; <BR>   pDatasetName = (IDatasetName)_pInFCName;<BR>   pDatasetName.setName(layname); <BR>   pDatasetName.setWorkspaceNameByRef(pOutWsName);<BR>   _sOutFCName = pDatasetName.getName();  <BR>  // IDatasetName pDatasetName1 = (IDatasetName)_pInFCName;</P>
<P>  } catch (UnknownHostException e) {<BR>   // TODO Auto-generated catch block<BR>   e.printStackTrace();<BR>  } catch (IOException e) {<BR>   // TODO Auto-generated catch block<BR>   e.printStackTrace();<BR>  }<BR> }<BR> <BR> public void ggg()<BR> {<BR>  <BR>  try {<BR>     IWorkspaceName              pINWsName        =           null;<BR>   IDatasetName pInDatasetName     ;<BR>   pINWsName = new WorkspaceName();<BR>   pINWsName.setPathName("D:\\DownLoads\\");<BR>   pINWsName.setWorkspaceFactoryProgID("esriCore.ShapefileWorkspaceFactory.1");<BR>   _pInFCName = new FeatureClassName();<BR>          pInDatasetName = (IDatasetName)_pInFCName;<BR>         pInDatasetName.setName(layname);<BR>          pInDatasetName.setWorkspaceNameByRef(pINWsName) ;<BR>  } catch (UnknownHostException e) {<BR>   // TODO Auto-generated catch block<BR>   e.printStackTrace();<BR>  } catch (IOException e) {<BR>   // TODO Auto-generated catch block<BR>   e.printStackTrace();<BR>  }</P>
<P> }<BR> public void ConvertFeatureClass(IFeatureClassName pInFCName,IWorkspaceName pOutWorkspaceName     ,IFeatureDatasetName pOutFDName ,String strOutFCName)<BR> {<BR>   //' Set Output feature class name<BR>  FeatureClassName pOutFCName ;<BR>  try {<BR>   pOutFCName = new FeatureClassName();   <BR>   IDatasetName  pDatasetName;<BR>   pDatasetName = (IDatasetName)pOutFCName;<BR>   pDatasetName.setName(strOutFCName);<BR>   pDatasetName.setWorkspaceNameByRef(pOutWorkspaceName);<BR>     <BR>   if (pOutFDName!=null)<BR>   {<BR>    pOutFCName.setFeatureDatasetNameByRef(null);<BR>   }      <BR>  //   ' Get the fields for the input feature class<BR>  //   ' and run them through the field checker<BR>  //   ' Strip field names which are qualified as Owner.TableName.FieldName<BR>  //   ' this will avoid breaking the field name width limit<BR>   IFields pFields;<BR>   IFields []pOutFields = null;<BR>   IFeatureClass pInFeatureClass = null;<BR>   IName pName ;<BR>   pName=(IName)pInFCName;<BR>   pInFeatureClass =new IFeatureClassProxy( pName.open()); <BR>  // pInFeatureClass.addField(fj);<BR>   IClone pSource ;<BR>   pSource = new ICloneProxy(pInFeatureClass.getFields());<BR>   pFields = new IFieldsProxy(pSource.esri_clone());<BR>   <BR>  //<BR>   ISQLSyntax pSQLSyntax;<BR>   pDatasetName = (IDatasetName)pInFCName;<BR>   pName =new INameProxy( pDatasetName.getWorkspaceName());<BR>   pSQLSyntax =new ISQLSyntaxProxy( pName.open());  //'Inline QI on Workspace object<BR>  //   <BR>   int i;<BR>   IField pField ;<BR>   IFieldEdit pFieldEdit;<BR>   String []sStrippedName=null;<BR>   String []sDbName=null;String []sOwnerName=new String[1]; String []sTableName=null ;<BR>  //   <BR>  ////   ' For each field, strip the name<BR>  ////   ' The check on Owner name avoids processing the Shape.Area and Shape.Len fields.<BR>  ////   ' (these are handled by the feature data converter).<BR>   for ( i = 0;i<pFields.getFieldCount()-1;i++ )<BR>   {<BR>    pField = pFields.getField(i);<BR>       sOwnerName[0] ="" ;<BR>       pSQLSyntax.parseColumnName(pField.getName(), sDbName, sOwnerName, sTableName, sStrippedName);<BR>       if (sOwnerName.length > 0) <BR>       {<BR>        pFieldEdit =new IFieldEditProxy( pField);<BR>        pFieldEdit.setName(pField.getName()) ;<BR>       }<BR>     }<BR>//<BR>//  pSQLSyntax.parseColumnName(fj.getName(), sDbName, sOwnerName, sTableName, sStrippedName);<BR>  //   <BR>   IEnumFieldError[] pEnumFieldError = null;<BR>   IFieldChecker pFieldChecker;<BR>   pFieldChecker = new FieldChecker();<BR>   pFieldChecker.validate(pFields, pEnumFieldError, pOutFields) ;<BR>  //   <BR>   IFeatureDataConverter pFeatureDataConverter ;<BR>   pFeatureDataConverter = new FeatureDataConverter();<BR>  //   <BR>  //   //' Do the conversion<BR>   IEnumInvalidObject pEnumInvalidObject;<BR>   pEnumInvalidObject = pFeatureDataConverter.convertFeatureClass(pInFCName,null,pOutFDName,pOutFCName,null,null,"",1000,0);<BR>  pOutWsName = null;<BR>   pOutWsName = null;<BR>   _sOutFCName = null; <BR>  } catch (UnknownHostException e) {<BR>   // TODO Auto-generated catch block<BR>   e.printStackTrace();<BR>  } catch (IOException e) {<BR>   // TODO Auto-generated catch block<BR>   e.printStackTrace();<BR>  }<BR>  }</P>
<P><BR>}</P>
举报 回复(0) 喜欢(0)     评分
benlb
路人甲
路人甲
  • 注册日期2005-11-21
  • 发帖数21
  • QQ
  • 铜币218枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2006-07-31 10:52
<P>错误代码是</P>
<P>AutomationException: 0x80041538 - Underlying DBMS error[Microsoft OLE DB Provider for SQL Server: ?÷±í????????±????¨??????±í 'ROAD' ???à?????¨?????? 'FID'??][sde.SDE.road] in 'esriDataSourcesGDB.SdeWorkspace.1'<BR> at com.esri.arcgis.geodatabase.FeatureDataConverter.convertFeatureClass(Unknown Source)<BR> at convertor.SHPToGeo.ConvertFeatureClass(SHPToGeo.java:208)<BR> at convertor.SHPToGeo.saveShap(SHPToGeo.java:87)<BR> at ServiceConnect.ServiceDateWriter.DataSDEIn(ServiceDateWriter.java:193)<BR> at ServiceConnect.ServiceDateWriter.execute(ServiceDateWriter.java:103)<BR> at XPub.executor.ImportToDB.execute(ImportToDB.java:65)<BR> at XPub.Server.handleInformation(Server.java:157)<BR> at com.teamax.xgis.geotools.xgisNIOServer$ThreadHandler.loadInformation(xgisNIOServer.java:454)<BR> at com.teamax.xgis.geotools.xgisNIOServer$ThreadHandler.handleBuffer(xgisNIOServer.java:392)<BR> at com.teamax.xgis.geotools.xgisNIOServer$ThreadHandler.run(xgisNIOServer.java:343)<BR> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)<BR> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)<BR> at java.lang.Thread.run(Unknown Source)</P>
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
5楼#
发布于:2006-07-31 10:36
请你把提示的错误信息贴出来
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
游客

返回顶部