使用node.js通过jdbc连接到impala

时间:2015-05-29 23:53:33

标签: node.js hadoop jdbc impala

我正在使用npm模块jdbc尝试连接到Cloudera Impala。

我已经为hiveserver2尝试了apache hive-jdbc-0.13.1-cdh5.3.3.jar 以及Cloudera JDBC ImpalaJDBC41.jar

var jdbc = new (require('jdbc'));

var config = {
  libpath: '/home/ubuntu/downloads/impala_jdbc/hive-jdbc-0.13.1-cdh5.3.3.jar',
  libs:'/home/ubuntu/downloads/impala_jdbc/lib/*.jar',
  drivername: 'org.apache.hive.jdbc.HiveDriver',
  url: 'jdbc:hive2://54.172.122.6:21050/;auth=noSasl' + process.argv[2] 
};

//Initialize jdbc object
jdbc.initialize(config, function(err, res){ if (err){ console.log(err); } });

jdbc.open(function(err, conn) {
  if (conn) {
    //Run first query
    jdbc.executeQuery('show databases', function(err, results){
      if (err){ console.log(err); }
      else if (results) { console.log(results); }
    }); 
  }else{
    console.log('Connection object:' + conn);
    console.log(err);
  }
});

jdbc.close(function(err){
  if(err) { console.log(err); }
  else { console.log('Connection closed successfully!');}
});

每当我运行它(纠正每个驱动程序路径后) 我得到以下

/home/ubuntu/PlayArea/ImpalaJDBC/node_modules/jdbc/lib/jdbc.js:22
   java.classpath.push.apply(java.classpath, self._config.libs);
                       ^
TypeError: Function.prototype.apply: Arguments list has wrong type
    at JDBCConn.initialize (/home/ubuntu/PlayArea/ImpalaJDBC/node_modules/jdbc/lib/jdbc.js:22:24)
    at Object.<anonymous> (/home/ubuntu/PlayArea/ImpalaJDBC/server.js:12:6)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:935:3

我假设我的libs路径找不到所需的所有罐子

0 个答案:

没有答案