【发布时间】:2021-01-20 12:19:14
【问题描述】:
我正在尝试使用 jaydebeapi 库从 python 连接到 Apache Drill。
我已经通过drill-embedded开启了嵌入式模式的drill,并且web ui在8047端口正确运行。然后,我尝试通过python脚本通过JDBC连接:
import jaydebeapi
import jpype
import os
DRILL_HOME = os.environ["DRILL_HOME"]
classpath = DRILL_HOME + "/jars/jdbc-driver/drill-jdbc-all-1.17.0.jar"
jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path=%s" % classpath)
conn = jaydebeapi.connect(
'org.apache.drill.jdbc.Driver',
'jdbc:drill:drillbit=localhost:8047'
)
但我收到此错误
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Traceback (most recent call last):
File "jaydebe_drill.py", line 10, in <module>
'jdbc:drill:drillbit=localhost:8047'
File "/Users/user/opt/anaconda3/lib/python3.7/site-packages/jaydebeapi/__init__.py", line 412,
in connect
jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
File "/Users/user/opt/anaconda3/lib/python3.7/site-packages/jaydebeapi/__init__.py", line 230,
in _jdbc_connect_jpype
return jpype.java.sql.DriverManager.getConnection(url, *dargs)
jpype._jexception.SQLNonTransientConnectionExceptionPyRaisable:
java.sql.SQLNonTransientConnectionException:
Failure in connecting to Drill: oadd.org.apache.drill.exec.rpc.ChannelClosedException:
Channel closed /127.0.0.1:62244 <--> localhost/127.0.0.1:8047.
有谁知道如何解决这个问题?
【问题讨论】:
-
(1) 您是否能够仅使用 Java 和 JDBC 连接到 Drill,即不使用 python 和 JayDeBeApi? (2) Drill 本身使用什么端口,而不是 Web 界面,使用什么端口?文档建议使用端口 2181 或 5181。尝试将 JDBC 驱动程序连接到端口 8047 上的 Web 界面将永远无法工作,并且可能会引发随机网络错误,例如您所看到的。
-
感谢您的帮助。显然,问题确实是连接端口。对于
drill-embedded,没有端口可供选择。我正在添加一个答案
标签: python jdbc apache-drill jpype jaydebeapi