Spark中的Informix连接问题

时间:2019-02-25 09:49:55

标签: apache-spark informix

使用下面的URL创建Informix连接对于独立的Java程序来说可以很好地工作,但是在使用Apache Spark查询数据时会出现问题。

   Vue.component('invoice-archive', {
    data: function () {
                return {
    invoices: [],
      }
    },
    created() { 
       this.myUpdateMethod();
    },
    methods:{
      myUpdateMethod: function(){
          var $this = this;
          let data = { 'id': installationId };

          this.getAjax('myUrlHere', data).then(function (result) {  
            if(!result.length ) return; // <-- This was the problem
            $this.invoices.push(JSON.parse(result));
    console.log($this.invoices); // This shows the expected content of my array
console.log($this.invoices.length); // This shows 0
        }); 
      },
       getAjax(url, data, success) {

                return new Promise(function (resolve, reject) {

                    var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');

                    xhr.onload = function () {

                        resolve(this.responseText);
                    }

                    xhr.onerror = reject;

                    xhr.open('POST', url);

                    xhr.setRequestHeader('Content-Type', "application/json;charset=UTF-8");

                    xhr.send(JSON.stringify(data));               

                });
            },
    });

sqlhosts文件位于正确的位置。它具有经过测试的正确条目。

下面观察到错误的堆栈跟踪。

    String INFORMIX_DRIVER = "com.informix.jdbc.IfxDriver";
    SparkConf sparkConf = new SparkConf()
            .setAppName("BuyerConnet-Pre-Final-SQ-Item-Export")
            .set("spark.cores.max", "64")
            .set("spark.executor.instances", "32")
            .set("spark.default.parallelism", "256")
            .set("spark.executor.memory", "1g")
            .set("hive.exec.dynamic.partition", "true")
            .set("hive.exec.dynamic.partition.mode", "nonstrict");

        SparkSession sparkSession = SparkSession.builder().config(sparkConf).enableHiveSupport().getOrCreate();

        String url = "jdbc:informix-sqli:DATABASE=imdct6;INFORMIXSERVER=importsp_redir;SQLH_TYPE=FILE;SQLH_FILE=/tmp/sqlhosts;DELIMIDENT=Y";

        Dataset<Row> dataSet =
            sparkSession.read().format("jdbc")
            .option("url", url)
            .option("dbtable", "( select * from table where table_status_code = 1000 ) AS TEST_DATA")    
            .option("user", "sample")
            .option("password", "sample")
            .option("driver", INFORMIX_DRIVER).load();

        dataSet.printSchema();

关于可能是什么问题或如何解决的任何建议?

0 个答案:

没有答案