Module Contents



General hook for JDBC access.



Context manager that suppresses the given exceptions and logs a warning message.


Context manager that suppresses the given exceptions and logs a warning message.

class airflow.providers.jdbc.hooks.jdbc.JdbcHook(*args, driver_path=None, driver_class=None, **kwargs)[source]

Bases: airflow.providers.common.sql.hooks.sql.DbApiHook

General hook for JDBC access.

JDBC URL, username and password will be taken from the predefined connection. Note that the whole JDBC URL must be specified in the “host” field in the DB. Raises an airflow error if the given connection id doesn’t exist.

To configure driver parameters, you can use the following methods:
  1. Supply them as constructor arguments when instantiating the hook.

  2. Set the “driver_path” and/or “driver_class” parameters in the “hook_params” dictionary when creating the hook using SQL operators.

  3. Set the “driver_path” and/or “driver_class” extra in the connection and correspondingly enable the “allow_driver_path_in_extra” and/or “allow_driver_class_in_extra” options in the “providers.jdbc” section of the Airflow configuration. If you’re enabling these options in Airflow configuration, you should make sure that you trust the users who can edit connections in the UI to not use it maliciously.

  4. Patch the JdbcHook.default_driver_path and/or JdbcHook.default_driver_class values in the file.

See JDBC connection for full documentation.

  • args – passed to DbApiHook

  • driver_path (str | None) – path to the JDBC driver jar file. See above for more info

  • driver_class (str | None) – name of the JDBC driver class. See above for more info

  • kwargs – passed to DbApiHook

property connection_extra_lower: dict[source]

connection.extra_dejson but where keys are converted to lower case.

This is used internally for case-insensitive access of jdbc params.

property driver_path: str | None[source]
property driver_class: str | None[source]
conn_name_attr = 'jdbc_conn_id'[source]
default_conn_name = 'jdbc_default'[source]
conn_type = 'jdbc'[source]
hook_name = 'JDBC Connection'[source]
supports_autocommit = True[source]
default_driver_path: str | None[source]
default_driver_class: str | None[source]
classmethod get_ui_field_behaviour()[source]

Get custom field behaviour.


Return a connection object.

set_autocommit(conn, autocommit)[source]

Set autocommit for the given connection.

  • conn (jaydebeapi.Connection) – The connection.

  • autocommit (bool) – The connection’s autocommit setting.


Get autocommit setting for the provided connection.


conn (jaydebeapi.Connection) – Connection to get autocommit setting from.


connection autocommit setting. True if autocommit is set to True on the connection. False if it is either not set, set to False, or the connection does not support auto-commit.

Return type


Was this entry helpful?