JDBC API和PostgreSQL Driver之间有什么区别?

huangapple go评论75阅读模式
英文:

What is the difference between JDBC API and PostgreSQL Driver?

问题

我正在创建一个新的Spring Boot项目(https://start.spring.io/),但我不太理解用于与关系型数据库交互的不同依赖关系。

混淆的重点在于"JDBC API"和"PostgreSQL驱动程序"。我的应用程序需要连接到一个PostgreSQL数据库。那么,以下哪些说法是正确的?

  1. JDBC API可用于连接并操作任何关系型(SQL)数据库(如MySQL、PostgreSQL等),并且不需要PostgresSQL驱动程序即可使JDBC API正常工作。

  2. 同时需要 JDBC API和PostgresSQL驱动程序才能使应用程序连接到PostgreSQL数据库。

  3. 依赖项PostgresSQL驱动程序包括JDBC API。

英文:

I am creating a new Spring Boot project (https://start.spring.io/), and I am not understanding the different dependencies provided for interfacing with relational databases.

The point of confusion is "JDBC API" and "PostgresSQL Driver". My app needs to connect to a PostgreSQL database. So, which of the following are true?

  1. JDBC API can be used to connect and operate with any relational (SQL) database (MySQL, PostgreSQL, etc.), and PostgresSQL Driver is not needed for JDBC API to work.

  2. Both JDBC API and PostgresSQL Driver are needed for an application to connect to a PostgreSQL database.

  3. The dependency PostgresSQL Driver includes JDBC API.

I have already googled about this, but there are only manuals of how to use them.

答案1

得分: 5

JDBC定义了一个与关系型数据库连接和操作的API。PostgreSQL驱动是这个API在PostgreSQL数据库上的实现。

如果没有底层驱动来实现JDBC API,是无法使用它的。不过,你可以直接使用驱动,但驱动通常对其API的稳定性几乎没有什么保证(当然,除了JDBC所承诺的内容),所以这可能是一个不好的主意。

英文:

JDBC defines an API to connect and work with relational databases. The PostgreSQL driver is an implementation of this API for the PostgreSQL database.

You cannot use the JDBC API without an underlying driver to implement it. You could, however, use the driver directly, but drivers usually have very little guarantees about the stability of their APIs (other than what's promised by JDBC, of course), so it would probably be a poor idea.

huangapple
  • 本文由 发表于 2020年9月1日 05:41:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/63678556.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定