无法在 Apache Airflow 中设置 DB2/DashDB JDBC 连接

编程入门 行业动态 更新时间:2024-10-19 16:22:46
本文介绍了无法在 Apache Airflow 中设置 DB2/DashDB JDBC 连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用 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 在这里 github/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 github/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):

github/apache/incubator-airflow/pull/2227

更多推荐

无法在 Apache Airflow 中设置 DB2/DashDB JDBC 连接

本文发布于:2023-11-24 04:35:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623992.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Airflow   Apache   JDBC   DashDB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!