首页 / 浏览问题 / 组件GIS / 问题详情
使用BDT将空间数据写入Oracle失败
16EXP 2023年05月18日
以下为报错信息,似乎是OracleFeatureRDDProvider只支持读取

Exception in thread "main" scala.NotImplementedError: provider is read-only
    at com.supermap.bdt.rddprovider.jdbc.OracleFeatureRDDProvider.createSchema(OracleFeatureRDDProvider.scala:98)
    at com.supermap.bdt.FeatureRDDProvider$class.save(FeatureRDDProvider.scala:74)
    at com.supermap.bdt.rddprovider.jdbc.OracleFeatureRDDProvider.save(OracleFeatureRDDProvider.scala:22)
    at OperateData.saveOracleFrddData(OperateData.scala:260)
    at MainMethod$.main(MainMethod.scala:13)
    at MainMethod.main(MainMethod.scala)

1个回答

您好,您那边代码是怎么写的呢?写入到Oracle需要使用SDX的方式去连接Oracle数据库来写入,不能使用JDBC的方式来连接,

params1.put(FeatureRDDProviderParams.ProviderType.key, "SDX")
9,232EXP 2023年05月18日
def saveOracleFrddData(featureRDD: FeatureRDD):FeatureRDD ={
  import java.util

  val params = new util.HashMap[String, java.io.Serializable]()
  params.put("dbtype", "oracle")
  params.put("host", "192.168.111.11")
  params.put("port", 1521)
  params.put("schema", "GTCAD")
  params.put("database", "ORCL")
  params.put("user", "*****")
  params.put("passwd", "******")
  params.put("numPartitions", 64)
  params.put("partitionField", "OBJECTID")
  params.put("providerType", "JDBC")
  params.put("dbtablename","SAVE_FRDD")
  FeatureRDDProviderFactory(params).save(featureRDD, params, featureRDD.schema.getTypeName)
  featureRDD
}

不使用JDBC的方式连接,可以参考以下代码:

   val params1 = new util.HashMap[String, java.io.Serializable]()
          params1.put(SDXFeatureRDDProviderParams.DBType.key, "oracleplus");
          params1.put(SDXFeatureRDDProviderParams.Server.key, "orcl")
          params1.put(SDXFeatureRDDProviderParams.User.key, "lcx")
          params1.put(SDXFeatureRDDProviderParams.PassWord.key, "123456")
          params1.put(FeatureRDDProviderParams.ProviderType.key, "SDX")
          FeatureRDDProviderFactory(params1).save(mysqlRDD, params1,"L20221101333")
为什么参数中不需要host
Server里面需要填写ip:端口号/实例名,比如 127.0.0.1:1521/orcl,给你的示例代码是把ip给抹掉了的
使用您给出的示例代码,执行后报错:

an exception caught at Environment.loadLibrary(), program will continue running.
an exception caught at Environment.loadLibrary(), program will continue running.
an exception caught at Environment.loadLibrary(), program will continue running.
an exception caught at Environment.loadLibrary(), program will continue running.
an exception caught at Environment.loadLibrary(), program will continue running.
an exception caught at Environment.loadLibrary(), program will continue running.
an exception caught at Environment.loadLibrary(), program will continue running.
an exception caught at Environment.loadLibrary(), program will continue running.
java.lang.UnsatisfiedLinkError: no WrapjCore in java.library.path
java.lang.UnsatisfiedLinkError: no WrapjAnalyst in java.library.path
java.lang.UnsatisfiedLinkError: no WrapjChart in java.library.path
java.lang.UnsatisfiedLinkError: no WrapjNav in java.library.path
java.lang.UnsatisfiedLinkError: no WrapjMapping in java.library.path
java.lang.UnsatisfiedLinkError: no WrapjPlot in java.library.path
java.lang.UnsatisfiedLinkError: no WrapjAnimation in java.library.path
java.lang.UnsatisfiedLinkError: no WrapjRealspace in java.library.path
java.lang.UnsatisfiedLinkError: com.supermap.data.EnvironmentNative.jni_InitEnvironment()V
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.supermap.data.EnvironmentNative.jni_GetBasePath()Ljava/lang/String;
  

Process finished with exit code 1
因为使用的是sdx引擎类型,需要有Java组件的环境变量。您那边在IDEA开发平台里面run Configruations对话框中设置environment cariables参数,参数值为path=oracle客户端路径;Java组件bin路径
环境变量设为:path=192.168.101.29:1521/C:\Program Files\Java\jdk1.8.0_201\bin

请问格式是否正确
path=E:\Environment\Oracle\Oracle\Client11gR2x64\;F:\TempSoft\iobjects\supermap-iobjectsjava-10.2.0-20128-90283-win64-all-Bin\Bin。第一个是Oracle客户端的路径,第二个是SuperMap iObjects Java的bin路径。
Oracle客户端是远程客户端
使用Oracle必须要在本地安装一个Oracle客户端,否则连不上Oracle数据库
...