Advertisement
Guest User

Untitled

a guest
Sep 16th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. var JDBC = require('jdbc');
  2. var jinst = require('jdbc/lib/jinst');
  3.  
  4. // isJvmCreated will be true after the first java call. When this happens, the
  5. // options and classpath cannot be adjusted.
  6. if (!jinst.isJvmCreated()) {
  7. // Add all java options required by your project here. You get one chance to
  8. // setup the options before the first java call.
  9. jinst.addOption("-Xrs");
  10. // Add all jar files required by your project here. You get one chance to
  11. // setup the classpath before the first java call.
  12. jinst.setupClasspath(['./drivers/hsqldb.jar',
  13. './drivers/derby.jar',
  14. './drivers/derbyclient.jar',
  15. './drivers/derbytools.jar',
  16. './lib/drivers/hive-jdbc-1.2.1.jar',
  17. './lib/drivers/hive-exec-1.2.1.jar',
  18. './lib/drivers/hive-common-1.2.1.jar',
  19. './lib/drivers/hive-metastore-1.2.1.jar',
  20. './lib/drivers/hive-service-1.2.1.jar',
  21. './lib/drivers/httpclient-4.3.jar',
  22. './lib/drivers/httpcore-4.3.jar',
  23. './lib/drivers/libthrift-0.9.1.jar',
  24. './lib/drivers/libfb303-0.9.0.jar',
  25. './lib/drivers/hadoop-common-2.7.1.jar',
  26. './lib/drivers/slf4j-api-1.7.21.jar',
  27. './lib/drivers/org-apache-commons-logging.jar'
  28. ]);
  29. }
  30.  
  31. var config = {
  32. url: 'jdbc:hive2://127.0.0.1:10000',
  33. user : 'demo',
  34. password: '',
  35. minpoolsize: 2,
  36. maxpoolsize: 3
  37. };
  38.  
  39. var testpool = null;
  40. var testconn = null;
  41. var hsqldb = new JDBC(config);
  42.  
  43. hsqldb.initialize(function(err) {
  44. if (err) {
  45. console.log(err);
  46. }
  47. });
  48.  
  49. hsqldb.reserve(function(err, connObj) {
  50. console.log("Using connection: " + connObj.uuid);
  51. var conn = connObj.conn;
  52. conn.createStatement(function(err, statement) {
  53. statement.executeQuery("select * from test1 limit 1",function(err,resultSet){
  54. //console.log(resultSet);
  55. resultSet.toObjArray(function(err, results) {
  56. console.log(results);
  57. });
  58.  
  59. });
  60. });
  61. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement