baztian / jaydebeapi

JayDeBeApi module allows you to connect from Python code to databases using Java JDBC. It provides a Python DB-API v2.0 to that database.
GNU Lesser General Public License v3.0
365 stars 148 forks source link

how to connect to phoenix,i need help #54

Open yyccww123 opened 7 years ago

yyccww123 commented 7 years ago

cmd : /usr/hdp/current/phoenix-client/bin/sqlline.py is work.

---------use phoenixdb is work, but It does not support kerberos. import phoenixdb import phoenixdb.cursor conn = phoenixdb.connect('http://localhost:8765', autocommit=True) cursor = conn.cursor() cursor.execute("SELECT count(1) FROM WILL_TEST5") print cursor.fetchone()[0]


I'm going to use jaydebeapi to connect to phoenix by jdbc.

import jaydebeapi conn = jaydebeapi.connect('org.apache.phoenix.jdbc.PhoenixDriver',['jdbc:phoenix:localhost:8765:/hbase-unsecure','', ''], '/usr/hdp/current/phoenix-client/phoenix-client.jar')

--Error: Traceback (most recent call last): File "", line 1, in File "build/bdist.linux-x86_64/egg/jaydebeapi/init.py", line 381, in connect File "build/bdist.linux-x86_64/egg/jaydebeapi/init.py", line 190, in _jdbc_connect_jpype File "/usr/lib64/python2.7/site-packages/JPype1-0.6.2-py2.7-linux-x86_64.egg/jpype/_jclass.py", line 55, in JClass raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name) jpype._jexception.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class org.apache.phoenix.jdbc.PhoenixDriver not found

-- import jaydebeapi conn = jaydebeapi.connect('org.apache.phoenix.jdbc.PhoenixDriver',['jdbc:phoenix:oc-etl-data-new-118,oc-etl-data-new-128,oc-etl-data-new-129:2181:/hbase-secure:ocdp/ocdp@ynmobile.com:/home/ocdp/keytabs/ocdp.keytab', '', ''],'/usr/hdp/current/phoenix-client/phoenix-client.jar')

error:

Traceback (most recent call last): File "", line 1, in File "build/bdist.linux-x86_64/egg/jaydebeapi/init.py", line 381, in connect File "build/bdist.linux-x86_64/egg/jaydebeapi/init.py", line 199, in _jdbc_connect_jpype RuntimeError: No matching overloads found. at native/common/jp_method.cpp:117

yyccww123 commented 7 years ago

new problem:

Traceback (most recent call last): File "", line 1, in File "build/bdist.linux-x86_64/egg/jaydebeapi/init.py", line 381, in connect File "build/bdist.linux-x86_64/egg/jaydebeapi/init.py", line 199, in _jdbc_connect_jpype jpype._jexception.SQLExceptionPyRaisable: java.sql.SQLException: org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=36, exceptions: Fri Sep 08 21:04:48 CST 2017, null, java.net.SocketTimeoutException: callTimeout=60000, callDuration=69739: row 'SYSTEM:CATALOG,,' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=oc-etl-data-new-117,16020,1504775489424, seqNum=0

faststare commented 7 years ago

You can decompile your db jar then copy it to org folder of jython. It works on sqlite-jdbc

weihanhua commented 5 years ago

Have you solve the problem? Can you list your solution procedures?