问题
Is it correct that the following two are different concepts:
- a JDBC driver (e.g. a JDBC driver for PostgreSQL) and
- JavaSE's java.sql package?
Is it correct that the JavaSE's java.sql package is an API built upon a JDBC driver, to become driver-agnostic?
In C for PostgreSQL,
- what is the equivalence to a JDBC driver, and
- what is the equivalence to java.sql?
- Is libpq more like a JDBC driver for PostgreSQL or JavaSE's java.sql package?
回答1:
Java SE' java.sql
package defines interfaces that Java libraries called JDBC drivers can implement to provide the functionality of working with a database in a way that's [almost] vendor agnostic. With JDBC (the java.sql
package), you [almost] never use vendor-specific classes, and just program against the interfaces.
libpq is something completely different - it's a c library that's completely specific to postgres. It makes no claim and no attempt to be a generic interface to program against any RDBMS.
来源:https://stackoverflow.com/questions/51312351/is-libpq-more-like-a-jdbc-driver-or-javases-java-sql-package