在进行JDBC链接时出现无法找到驱动,然后修改驱动既可以

    1. /*hiverserver 版本使用此驱动*/Technorati 标记: hadoop,hive,jdbc
    2. //private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
    3. /*hiverserver2 版本使用此驱动*/
    4. private static String driverName = "org.apache.hive.jdbc.HiveDriver";
    5. public static void main(String[] args) throws SQLException {
    6. try {
    7. Class.forName(driverName);
    8. } catch (ClassNotFoundException e) {
    9. e.printStackTrace();
    10. System.exit(1);
    11. }
    12. /*hiverserver 版本jdbc url格式*/
    13. //Connection con = DriverManager.getConnection("jdbc:hive://hostip:10000/default", "", "");
    14. /*hiverserver2 版本jdbc url格式*/
    15. Connection con = DriverManager.getConnection("jdbc:hive2://hostip:10000/default", "hive", "hive");
    16. Statement stmt = con.createStatement();
    17. //参数设置测试
    18. //boolean resHivePropertyTest = stmt
    19. // .execute("SET tez.runtime.io.sort.mb = 128");

    连接hive时出现

    1. Caused by: java.net.ConnectException: Connection refused (Connection refused)

    解决方案: