-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (28 loc) · 938 Bytes
/
server.js
File metadata and controls
32 lines (28 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var jdbc = new (require('jdbc'));
var config = {
libpath: '/usr/hdp/current/phoenix-client/phoenix-client.jar',
drivername: 'org.apache.phoenix.jdbc.PhoenixDriver',
url: 'jdbc:phoenix:' + process.argv[2] //example: localhost:2181:/hbase-unsecure
}
//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('SELECT * FROM web_stat', function(err, results){
if (err){ console.log(err); }
else if (results) { console.log(results); }
});
//Run second query
jdbc.executeQuery('select count(*) from web_stat', function(err, 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!');}
});