在python中使用连接到配置单元的jdbc时出错

sz81bmfz  于 2021-06-27  发布在  Hive
关注(0)|答案(0)|浏览(218)

我是python的新手,所以要友善。我正试图用jdbc从hive中获取数据。我做了所有必要的安装。但是在运行这个简单的代码时,会返回一个错误。我需要一些帮助来理解哪里出了问题,以及我该如何解决这个问题。

import jaydebeapi as jdba
def get_hive_jdbc_con():
    driver="org.apache.hive.jdbc.HiveDriver"
    conn_url="jdbc:hive2://tlgdhadlap12.r-office.com:10000/default"
    auth_lst=["un","pw"]
    conn = jdba.connect(driver,conn_url,auth_lst,"c:/app/hive-jdbc-1.2.1000.2.6.4.0-91-standalone.jar")
    return conn

get_hive_jdbc_con()

返回错误:

Traceback (most recent call last):

  File "C:/../PycharmProjects/untitled/venv/Scripts/GilaTest", line 10, in <module>

    get_hive_jdbc_con()

  File "C:/../PycharmProjects/untitled/venv/Scripts/GilaTest", line 7, in get_hive_jdbc_con

    conn = jdba.connect(driver,conn_url,auth_lst,"c:/app/hive-jdbc-1.2.1000.2.6.4.0-91-standalone.jar")

  File "C:\..\PycharmProjects\untitled\venv\lib\site-packages\jaydebeapi\__init__.py", line 68, in connect

    connection = gateway.jvm.DriverManager.getConnection(*driver_args)

  File "C:\..\PycharmProjects\untitled\venv\lib\site-packages\py4j\java_gateway.py", line 1160, in __call__

    answer, self.gateway_client, self.target_id, self.name)

  File "C:\..\PycharmProjects\untitled\venv\lib\site-packages\py4j\protocol.py", line 324, in get_return_value

    format(target_id, ".", name, value))

py4j.protocol.Py4JError: An error occurred while calling z:java.sql.DriverManager.getConnection. Trace:

py4j.Py4JException: Method getConnection([class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String]) does not exist

                at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)

                at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:339)

                at py4j.Gateway.invoke(Gateway.java:276)

                at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)

                at py4j.commands.CallCommand.execute(CallCommand.java:79)

                at py4j.GatewayConnection.run(GatewayConnection.java:214)

                at java.lang.Thread.run(Unknown Source)

谢谢你的帮助!吉拉

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题