Unable to setup a DB2 / DashDB JDBC Connection in Apache Airflow

♀尐吖头ヾ 提交于 2020-01-24 13:33:12

问题


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

I tried to run a simple query (in the ad hoc UI) and always get the same error

java.lang.RuntimeException: Class com.ibm.db2.jcc.DB2Driver.class not found

Did anybody need to setup a DB2 / DashDB connection in Apache Airflow before?

Found nothing on the web about that.

Thanks


回答1:


May be stupid thing to check but make sure you dont have any leading blank space in connection url, driver path and driver class. Also "airflow" user (or whoever is running airflow process should have access to the driver path.




回答2:


If you haven't still figured this out, I ran into same problem.

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.

In particular is missing the second parameter, which should be the URL of the connection.

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    

Notice the host added to the call to jaydebeapi.connect.

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



来源:https://stackoverflow.com/questions/41912554/unable-to-setup-a-db2-dashdb-jdbc-connection-in-apache-airflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!