英文:
What is the difference between JDBC API and PostgreSQL Driver?
问题
我正在创建一个新的Spring Boot项目(https://start.spring.io/),但我不太理解用于与关系型数据库交互的不同依赖关系。
混淆的重点在于"JDBC API"和"PostgreSQL驱动程序"。我的应用程序需要连接到一个PostgreSQL数据库。那么,以下哪些说法是正确的?
-
JDBC API可用于连接并操作任何关系型(SQL)数据库(如MySQL、PostgreSQL等),并且不需要PostgresSQL驱动程序即可使JDBC API正常工作。
-
同时需要 JDBC API和PostgresSQL驱动程序才能使应用程序连接到PostgreSQL数据库。
-
依赖项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?
-
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.
-
Both JDBC API and PostgresSQL Driver are needed for an application to connect to a PostgreSQL database.
-
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论