Advertisement
Guest User

HiveClientJdbc.java

a guest
Sep 6th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. package test;
  2. import java.sql.Connection;
  3. import java.sql.DriverManager;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import java.sql.Statement;
  7. public class HiveClientJdbc {
  8. private static final String HIVE_DRIVER = “org.apache.hadoop.hive.jdbc.HiveDriver”;
  9. private static final String CONNECTION_URL = “jdbc:hive://localhost:10000/default”;
  10. public static void main(String[] args) throws SQLException, ClassNotFoundException {
  11. Class.forName(HIVE_DRIVER);
  12. Connection con = DriverManager.getConnection(CONNECTION_URL, “”, “”);
  13. Statement stmt = con.createStatement();
  14. ResultSet rslt = stmt.executeQuery(“select count(*) from retail_demo.email_addresses_dim_hive”);
  15. if (rslt.next()) {
  16. System.out.println(rslt.getInt(1));
  17. }
  18. con.close();
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement