无法在 Apache Airflow 中设置 DB2/DashDB JDBC 连接 [英] Unable to setup a DB2 / DashDB JDBC Connection in Apache Airflow
问题描述
我正在尝试使用 Airflow UI 创建 DB2/DashDB 连接.我添加了 db2jcc4.jar 驱动程序并提供了路径以及类名 com.ibm.db2.jcc.DB2Driver.class
I'm trying to create a DB2 / DashDB connection using the Airflow UI. I have added the db2jcc4.jar driver and provided the path as well as the class name com.ibm.db2.jcc.DB2Driver.class
我尝试运行一个简单的查询(在 ad hoc UI 中)并且总是得到相同的错误
I tried to run a simple query (in the ad hoc UI) and always get the same error
java.lang.RuntimeException:找不到类 com.ibm.db2.jcc.DB2Driver.class
java.lang.RuntimeException: Class com.ibm.db2.jcc.DB2Driver.class not found
之前有人需要在 Apache Airflow 中设置 DB2/DashDB 连接吗?
Did anybody need to setup a DB2 / DashDB connection in Apache Airflow before?
在网上找不到任何关于此的内容.
Found nothing on the web about that.
谢谢
推荐答案
如果你还没有弄清楚,我遇到了同样的问题.
If you haven't still figured this out, I ran into same problem.
通过一些调试,我发现文件 jdbc_hook.py
在这里 https://github.com/apache/incubator-airflow/blob/master/airflow/hooks/jdbc_hook.py#L55jaydebeapi.connect
方法调用中缺少 1 个参数.
With some debugging I came to find that the file jdbc_hook.py
here https://github.com/apache/incubator-airflow/blob/master/airflow/hooks/jdbc_hook.py#L55
is missing 1 parameter expected in the jaydebeapi.connect
method call.
特别是缺少第二个参数,它应该是连接的URL.
In particular is missing the second parameter, which should be the URL of the connection.
我把get_conn
方法里面的代码改成下面这样试试,效果不错.
I changed the code inside the method get_conn
to the following to try out, and it worked.
def get_conn(self):
......
conn = jaydebeapi.connect(jdbc_driver_name,
host,
driver_args=[str(login), str(psw)],
jars=jdbc_driver_loc)
return conn
注意 host
添加到对 jaydebeapi.connect
的调用中.
Notice the host
added to the call to jaydebeapi.connect
.
我想开一个 PR,但后来查看,他们已经在几个地方有一些东西(在 Airflow 的 PR 中搜索 jdbc
):
I was thinking of opening a PR, but then reviewing, they have already something in a couple of places (search for jdbc
in Airflow's PRs):
https://github.com/apache/incubator-airflow/pull/2227
这篇关于无法在 Apache Airflow 中设置 DB2/DashDB JDBC 连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!