Hive架构分析
一.Hive三种设计模式
1.默认配置【使用Netty存储元数据】
2.mysql【使用mysql存储元数据】
3.配置Thrift【使用mysql存储元数据】
二.执行步骤
三.scala访问Hive
1 package big.data.analyse.hive 2 3 import java.sql.DriverManager 4 5 /** 6 * 使用jdbc连接hive 7 * Created by zhen on 2019/6/18. 8 */ 9 object ScalaJDBCHive { 10 def main(args: Array[String]) { 11 Class.forName("org.apache.hive.jdbc.HiveDriver") 12 val conn = DriverManager.getConnection("jdbc:hive2://Master:10000/hive", "username", "password") 13 try{ 14 val stat = conn.createStatement() 15 val rs = stat.executeQuery("select name,age from user where name='zhangsan'") 16 while(rs.next()){ 17 val name = rs.getString("name") 18 val age = rs.getString("age") 19 println("name:" + name + ",age:" + age) 20 } 21 }catch{ 22 case e : Exception => e.printStackTrace() 23 }finally{ 24 conn.close() 25 } 26 } 27 }