2016-07-30 8 views
3

私のノードjsアプリケーションをハイブに接続するのにnode-hiveとthriftを使用しましたが、どれも動作しません。ハイブに接続するための他のノードモジュールはありますか?node.jsアプリケーションをハイブに接続する際のエラー

+0

をフェッチあなたがチェックされていますhttps://github.com/wdavidw/node-thrift-hiveとhttps://github.com/forward/node-hiveを? – vanloc

答えて

3

ノードnode-thrift-hivenode-hive両方のモジュールは放棄されていますが、4〜5年前にコミットされません。同じ問題があり、ノード0.12を使用しています。

ステップ-1:手順-1に従うことをしたくない場合は、セットアップHiveserver2に持って、私のハイブのバージョンが1.2とHadoopのバージョン2.7

https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2

で、その後4.5にあなたのノードのjsをアップグレード>私は、JDBCドライバを経由して接続しようので、私は私のノードのバージョンをアップグレードしたくない私の場合はjshs2 npm

を使用JDBC NPM

ステップ-2:ハイブを接続するためのコードの下に使用し、データ

var JDBC = require('jdbc'); 
var jinst = require('jdbc/lib/jinst'); 

// isJvmCreated will be true after the first java call. When this happens, the 
// options and classpath cannot be adjusted. 
if (!jinst.isJvmCreated()) { 
    // Add all java options required by your project here. You get one chance to 
    // setup the options before the first java call. 
    jinst.addOption("-Xrs"); 
    // Add all jar files required by your project here. You get one chance to 
    // setup the classpath before the first java call. 
    jinst.setupClasspath(['./drivers/hsqldb.jar', 
         './drivers/derby.jar', 
         './drivers/derbyclient.jar', 
         './drivers/derbytools.jar', 
         './lib/drivers/hive-jdbc-1.2.1.jar', 
         './lib/drivers/hive-exec-1.2.1.jar', 
         './lib/drivers/hive-common-1.2.1.jar', 
         './lib/drivers/hive-metastore-1.2.1.jar', 
         './lib/drivers/hive-service-1.2.1.jar', 
         './lib/drivers/httpclient-4.3.jar', 
         './lib/drivers/httpcore-4.3.jar', 
         './lib/drivers/libthrift-0.9.1.jar', 
         './lib/drivers/libfb303-0.9.0.jar', 
         './lib/drivers/hadoop-common-2.7.1.jar', 
         './lib/drivers/slf4j-api-1.7.21.jar', 
         './lib/drivers/org-apache-commons-logging.jar' 
         ]); 
} 

var config = { 
    url: 'jdbc:hive2://127.0.0.1:10000', 
    user : 'demo', 
    password: '', 
    minpoolsize: 2, 
    maxpoolsize: 3 
}; 

var testpool = null; 
var testconn = null; 
var hsqldb = new JDBC(config); 

hsqldb.initialize(function(err) { 
    if (err) { 
    console.log(err); 
    } 
}); 

hsqldb.reserve(function(err, connObj) { 
    console.log("Using connection: " + connObj.uuid); 
    var conn = connObj.conn; 
    conn.createStatement(function(err, statement) { 
     statement.executeQuery("select * from test1 limit 1",function(err,resultSet){ 
      //console.log(resultSet); 
      resultSet.toObjArray(function(err, results) { 
       console.log(results); 
      }); 

     }); 
    });  
}); 
+0

github link if possible –

+0

私は単純なサーバーをJavaで書くだけです。 –

+0

@AlexanderMillsはい、できますが、これはNode.jsの解決策です。接続libが拒否されています –

関連する問題