Advertisement
Guest User

Untitled

a guest
Apr 16th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <%
  2. //create connection
  3. String user = "wilianto";
  4. String pass = "";
  5. String driver = "org.apache.hive.jdbc.HiveDriver";
  6. String url = "jdbc:hive2://localhost:10000/default";
  7. Class.forName(driver).newInstance();
  8. Connection con = DriverManager.getConnection(url, user, pass);
  9. if(con == null){
  10. out.println("Not connected!");
  11. }else{
  12. out.println("Connected!");
  13. }
  14.  
  15. //do query
  16. Statement statement = con.createStatement();
  17. ResultSet rs = statement.executeQuery("SELECT * FROM destination_trends_summary");
  18. while(rs.next()){
  19. out.println(rs.getString("destination") + ", " + rs.getString("post_date") + ", " + rs.getString("qty") + "<br>");
  20. }
  21. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement