分享

idea通过jdbc连接hive一直报错

两天了,网上的方法都试过了。在本地的cmd   telnet  192.168.111.131 10002 是没问题的。


然后 直接调试,想要通过

public class DataAnaly {
    private  static String DriverName = "org.apache.hive.jdbc.HiveDriver";

    public static void main(String[] args) throws SQLException {
        System.out.println("hello world");

        try{
            Class.forName(DriverName);
        }catch(ClassNotFoundException e){
            e.printStackTrace();
            System.exit(1);
        }

        try {
            Connection con = DriverManager.getConnection(
                    "jdbc:hive2://192.168.111.131:10002/default", "hive", "mysql");
            System.out.println("connect success");
        }catch(Exception e){
            e.printStackTrace();
            System.exit(1);
        }

        System.out.println("end");
}

去连接,但是报错,

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/HttpRequestInterceptor
        at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
        at java.sql.DriverManager.getConnection(DriverManager.java:571)
        at java.sql.DriverManager.getConnection(DriverManager.java:215)
        at com.ghost.java.DataAnaly.main(DataAnaly.java:39)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpRequestInterceptor
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        ... 9 more

Process finished with exit code 1
额,好像这次的错误跟上回还不一样。

已有(4)人评论

跳转到指定楼层
starrycheng 发表于 2016-6-24 17:25:41


应该还是缺包或则没有引进来。

1.png

详细参考:
http://grepcode.com/file/reposit ... HiveConnection.java


回复

使用道具 举报

easthome001 发表于 2016-6-24 17:28:42
也可能是版本不兼容造成的。
回复

使用道具 举报

liuzhixin137 发表于 2016-6-27 09:37:07
easthome001 发表于 2016-6-24 17:28
也可能是版本不兼容造成的。

我查过,版本兼容

hive  2.0.0
hadoop 2.6.0
回复

使用道具 举报

easthome001 发表于 2016-6-27 21:47:00
liuzhixin137 发表于 2016-6-27 09:37
我查过,版本兼容

hive  2.0.0

jdbc包,是否兼容hive。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条