在进行JDBC链接时出现无法找到驱动,然后修改驱动既可以
/*hiverserver 版本使用此驱动*/Technorati 标记: hadoop,hive,jdbc//private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";/*hiverserver2 版本使用此驱动*/private static String driverName = "org.apache.hive.jdbc.HiveDriver";public static void main(String[] args) throws SQLException {try {Class.forName(driverName);} catch (ClassNotFoundException e) {e.printStackTrace();System.exit(1);}/*hiverserver 版本jdbc url格式*///Connection con = DriverManager.getConnection("jdbc:hive://hostip:10000/default", "", "");/*hiverserver2 版本jdbc url格式*/Connection con = DriverManager.getConnection("jdbc:hive2://hostip:10000/default", "hive", "hive");Statement stmt = con.createStatement();//参数设置测试//boolean resHivePropertyTest = stmt// .execute("SET tez.runtime.io.sort.mb = 128");
连接hive时出现
Caused by: java.net.ConnectException: Connection refused (Connection refused)
解决方案:
