Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to Hive using python's Jaydebeapi

I'm trying to connect to a hive server using jaydebeapi python lib, I'm getting an error. I'm not experienced in JAVA. What might the problem be, or how can I debug it?

./beeline-jdbc.py 

CLASSPATH is :/usr/hdp/2.4.3.0-227/hadoop/conf:/usr/hdp/2.4.3.0-227/hadoop/lib/*:/usr/hdp/2.4.3.0-227/hadoop/.//*:/usr/hdp/2.4.3.0-227/hadoop-hdfs/./:/usr/hdp/2.4.3.0-227/hadoop-hdfs/lib/*:/usr/hdp/2.4.3.0-227/hadoop-hdfs/.//*:/usr/hdp/2.4.3.0-227/hadoop-yarn/lib/*:/usr/hdp/2.4.3.0-227/hadoop-yarn/.//*:/usr/hdp/2.4.3.0-227/hadoop-mapreduce/lib/*:/usr/hdp/2.4.3.0-227/hadoop-mapreduce/.//*::mysql-connector-java-5.1.37:mysql-connector-java-5.1.37-bin.jar:mysql-connector-java-5.1.37.zip:mysql-connector-java.jar:/usr/hdp/2.4.3.0-227/tez/*:/usr/hdp/2.4.3.0-227/tez/lib/*:/usr/hdp/2.4.3.0-227/tez/conf:/usr/hdp/current/hadoop-client/*:/usr/hdp/current/hive-client/lib/*:/usr/hdp/current/hadoop-client/client/*

Traceback (most recent call last):
  File "./beeline-jdbc.py", line 18, in <module>
    , hivejar)
  File "/home/dev/lib/JayDeBeApi-1.0.0-py2.6.egg/jaydebeapi/__init__.py", line 380, in connect
    jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
  File "/home/dev/lib/JayDeBeApi-1.0.0-py2.6.egg/jaydebeapi/__init__.py", line 199, in _jdbc_connect_jpype
    return jpype.java.sql.DriverManager.getConnection(url, *dargs)
RuntimeError: No matching overloads found. at native/common/jp_method.cpp:117

An the script:

#!/usr/bin/env python

import jaydebeapi
import os

principal='hive/[email protected]'
server='localhost'
port=10000
database='tsz'
hivejar='/usr/hdp/current/hive-client/lib/hive-jdbc.jar'

url=("jdbc:hive2://" + server + ":" + str(port) + "/default;principal="
    + principal + ";")

print 'CLASSPATH is '+os.environ['CLASSPATH']

c=jaydebeapi.connect("org.apache.hive.jdbc.HiveDriver", [ url, '', '']
    , hivejar)

cursor=c.cursor()
like image 256
Neil H Watson Avatar asked Feb 09 '17 15:02

Neil H Watson


1 Answers

this is an example of demo, try this please. https://github.com/ghostyusheng/python-hive-jdbc

like image 173
ghostyusheng Avatar answered Sep 28 '22 09:09

ghostyusheng