首页 / 浏览问题 / 组件GIS / 问题详情
空间数据写入Oracle:open datasource failed
16EXP 2023年05月22日

代码:

def saveOracleFrddData(featureRDD: FeatureRDD):Any ={
  import java.util
  import com.supermap.bdt.paranamer.{FeatureRDDProviderParams, SDXFeatureRDDProviderParams}
  val params = new util.HashMap[String, java.io.Serializable]()
  params.put(SDXFeatureRDDProviderParams.DBType.key, "ORACLESPATIAL")
  params.put(SDXFeatureRDDProviderParams.Server.key, "192.168.101.29:1521/ORCL")
  params.put(SDXFeatureRDDProviderParams.User.key, "GTCAD")
  params.put(SDXFeatureRDDProviderParams.PassWord.key, "gtis")
  params.put(FeatureRDDProviderParams.ProviderType.key, "SDX")
  FeatureRDDProviderFactory(params).save(featureRDD, params, "SAVEORACLEDATA")
}

报错:Exception in thread "main" java.lang.IllegalArgumentException: open datasource failed
    at com.supermap.bdt.rddprovider.sdx.SDXUtils$.getDataSource(SDXUtils.scala:96)
    at com.supermap.bdt.rddprovider.sdx.SDXFeatureRDDProvider.createSchema(SDXFeatureRDDProvider.scala:127)
    at com.supermap.bdt.FeatureRDDProvider$class.save(FeatureRDDProvider.scala:74)
    at com.supermap.bdt.rddprovider.sdx.SDXFeatureRDDProvider.save(SDXFeatureRDDProvider.scala:34)
    at OperateData.saveOracleFrddData(OperateData.scala:281)
    at MainMethod$.main(MainMethod.scala:12)
    at MainMethod.main(MainMethod.scala)

1个回答

在超图的数据源里oraclespatial和oracleplus两个类别数据源有区别,oracleplus数据源是超图的sdx引擎实现的;oraclespatial是oracle空间数据标准。其用法有写不一样:

oracleplus数据源的连接示例:

val params = new java.util.HashMap[String, java.io.Serializable]()
params.put(SDXFeatureRDDProviderParams.DBType.key, "OraclePlus")
params.put(SDXFeatureRDDProviderParams.Server.key, "127.0.0.1:1521/orcl")
params.put(SDXFeatureRDDProviderParams.User.key, "c##mytest")
params.put(SDXFeatureRDDProviderParams.PassWord.key, "supermap")
params.put(FeatureRDDProviderParams.ProviderType.key, "sdx")
val sdx = new SDXFeatureRDDProvider()
val rdd = sdx.rdd(new Configuration(), ss.sparkContext, params, new Query("NewPoint"))


oraclespatial数据源连接示例:

val params = new java.util.HashMap[String, java.io.Serializable]()
params.put(JDBCFeatureRDDProviderParams.DBType.key, "oracle")
params.put(JDBCFeatureRDDProviderParams.Host.key, "127.0.0.1")
params.put(JDBCFeatureRDDProviderParams.Port.key, 1521)
params.put(JDBCFeatureRDDProviderParams.Schema.key, "public")
params.put(JDBCFeatureRDDProviderParams.DataBase.key, "orcl")
params.put(JDBCFeatureRDDProviderParams.User.key, "aaa")
params.put(JDBCFeatureRDDProviderParams.PassWord.key, "aaa")
params.put(FeatureRDDProviderParams.ProviderType.key, "JDBC")

注意:连接oracle数据源依赖各节点的oracle客户端环境变量。

1,505EXP 2023年05月23日
...