简体   繁体   中英

How to connect in Hive using Java?

I'm trying to find a way to connect my web app to Hive by using Java . Does anybody here know how to do it? I have no idea and experience in doing it and there are not enough tutorials and step-by-step process available on the net. Thanks in advance!

Class.forName("org.apache.hadoop.hive.jdbc.HiveDriver");
Connection con = DriverManager.getConnection("jdbc:hive://localhost:<port>/<dbname>", "<user>", "<password>");
Statement stmt = con.createStatement();
ResultSet res = sql.executeQuery("SELECT * FROM tablename");

This is a sample HIVE connection code. You need to add "HiveDriver" jar to the class path

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM