# JDBC 驱动程序

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/idea/llms.txt).

JDBC（Java Database Connectivity）驱动程序 使 IDE 能够连接到数据库并查询数据库。

IntelliJ IDEA 不包含捆绑的驱动程序，以减小安装软件包的大小，并使每个 IDE 版本的驱动程序版本保持最新。

可以在 IDE 中下载 JDBC 驱动程序，也可以手动下载：

* 在 [创建新数据源](managing-data-sources.html#create_a_data_source)以用于 数据源和驱动程序 对话框 ( `Shift+Enter` (Windows), `⌘ I` (macOS), `⇧ ⏎` (IntelliJ IDEA Classic (macOS)), `⌘ I` (macOS System Shortcuts), `Shift+Enter` (XWin), `Shift+Enter` (GNOME), `Shift+Enter` (KDE), `Shift+Enter` (Emacs), `Shift+Enter` (Sublime Text), `⌘ I` (Sublime Text (macOS)), `Shift+Enter` (Visual Studio), `⌘ I` (Visual Studio (macOS)), `Shift+Enter` (NetBeans), `Shift+Enter` (Eclipse), `⌘ I` (Eclipse (macOS)) ) 中的数据库连接时，IntelliJ IDEA 会提供一个链接，用于下载缺失的驱动程序。 ![下载缺失的驱动文件链接](https://resources.jetbrains.com/help/img/idea/2026.3/db_connection_download_missing_drivers_link.png)

* 对于直接下载链接，请参阅 [JetBrains JDBC 驱动程序](https://www.jetbrains.com/zh-cn/datagrip/jdbc-drivers/) 页面。

下载的 JDBC 驱动程序的位置是 [IntelliJ IDEA 配置目录](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#config-directory)。

如果您需要从 Maven 镜像或您自己的存储库下载驱动程序，IntelliJ IDEA 将使用  `$USER_HOME$/.m2/settings.xml`  文件中配置的内容。 有关该文件的更多信息，请参阅 [官方文档](https://maven.apache.org/settings.html)。

您也可以为数据源 [指定您的驱动程序](#configure_a_jdbc_driver_for_an_existing_data_source)，而不是使用提供的驱动程序。 自定义 JDBC 驱动程序可以从官方数据库供应商网站、开源存储库、第三方供应商、开发者社区和论坛等地获取。

Procedure: 更改驱动程序版本

1. 通过以下任一方式打开数据源属性：

* 在 数据库 工具窗口工具栏中，点击 ![数据源图标](https://resources.jetbrains.com/help/img/idea/2026.3/database-plugin.icons.expui.manageDataSources.svg) 数据源 。

* 请按 `Shift+Enter` (Windows), `⌘ I` (macOS), `⇧ ⏎` (IntelliJ IDEA Classic (macOS)), `⌘ I` (macOS System Shortcuts), `Shift+Enter` (XWin), `Shift+Enter` (GNOME), `Shift+Enter` (KDE), `Shift+Enter` (Emacs), `Shift+Enter` (Sublime Text), `⌘ I` (Sublime Text (macOS)), `Shift+Enter` (Visual Studio), `⌘ I` (Visual Studio (macOS)), `Shift+Enter` (NetBeans), `Shift+Enter` (Eclipse), `⌘ I` (Eclipse (macOS)) .

![打开数据源和驱动程序对话框](https://resources.jetbrains.com/help/img/idea/2026.3/open_data_sources_and_drivers_dialog.png)

2. 在   数据源和驱动程序   对话框中，点击   驱动程序   选项卡页，然后选择您想要修改的驱动条目。

3. 点击数据源设置中的   驱动程序   链接。

某些数据源有一个驱动程序的列表，这些驱动程序适用于不同的版本（例如， MySQL）。 在这些情况下，从列表中选择   转到 driver  。

4. 在   驱动文件   窗格中，点击版本号并选择所需的驱动程序版本。

[Video](https://resources.jetbrains.com/help/img/idea/2026.3/db_change_the_driver_version.mp4)

Procedure: 为现有数据源配置 JDBC 驱动程序

您可以向现有驱动程序添加库，或完全替换驱动程序。

为了正常工作，一些 JDBC 驱动程序需要与驱动程序一同提供库文件的路径。 有关库路径的更多信息，请参阅 [用户驱动程序的库路径](other-databases.html#library-paths-for-user-drivers)。

1. 通过以下任一方式打开数据源属性：

* 在 数据库 工具窗口工具栏中，点击 ![数据源图标](https://resources.jetbrains.com/help/img/idea/2026.3/database-plugin.icons.expui.manageDataSources.svg) 数据源 。

* 请按 `Shift+Enter` (Windows), `⌘ I` (macOS), `⇧ ⏎` (IntelliJ IDEA Classic (macOS)), `⌘ I` (macOS System Shortcuts), `Shift+Enter` (XWin), `Shift+Enter` (GNOME), `Shift+Enter` (KDE), `Shift+Enter` (Emacs), `Shift+Enter` (Sublime Text), `⌘ I` (Sublime Text (macOS)), `Shift+Enter` (Visual Studio), `⌘ I` (Visual Studio (macOS)), `Shift+Enter` (NetBeans), `Shift+Enter` (Eclipse), `⌘ I` (Eclipse (macOS)) .

![打开数据源和驱动程序对话框](https://resources.jetbrains.com/help/img/idea/2026.3/open_data_sources_and_drivers_dialog.png)

2. 点击数据源设置中的   驱动程序   链接并选择   前往 Driver  。

3. 点击所提供的驱动程序条目，然后点击   移除   （ !["移除"按钮](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.remove.svg)）。

要撤销更改，点击窗口右下角的   回滚更改   图标（ !["回滚更改"图标 ](https://resources.jetbrains.com/help/img/idea/2026.3/app.diff.revert.svg)）。

4. 在   驱动程序文件   面板中，点击   添加   图标（ !["添加"图标](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg)）并选择   自定义 JARs…  。

5. 在文件浏览器中，导航到 JDBC 驱动的 JAR 文件，选择它，然后点击   OK  。

6. 在   类   字段中，指定您想要用于驱动程序的值。

驱动程序类 是 JDBC 驱动程序的驱动程序特定主类。 对于您使用的 JDBC 驱动程序的适当驱动程序类，请参考驱动程序的文档。

> **Note:**
> 如果该字段为空，或者预定义值与驱动程序所需的值不同，请手动指定所需值。

7. 如果您的自定义驱动程序需要额外的属性，请转到对话框中的   高级   选项卡。 在属性窗格中，在   名称   和   值   列的最后一行中输入附加属性的名称和值，其中显示 <用户定义> 和 <值>。

8. 点击   应用  。

> **Tip:**
> 有关 JDBC 驱动程序设置的更多信息，请参阅 [对话框参考主题](data-sources-and-drivers-dialog.html#driver)。

[Video](https://resources.jetbrains.com/help/img/idea/2026.3/db_add_user_driver_to_connection.mp4)

## See also

### 参考

[Drivers tab of the 数据源和驱动程序 dialog](data-sources-and-drivers-dialog.html#driver)

