Is it possible to use JDBC as an abstraction layer for RDBMS?

跟風遠走 提交于 2019-12-06 06:02:17

No this is not possible because they serve two completely different purposes.

JDBC is an abstraction of the DBMS communication protocol, whereas SQL is a query language.

The queries written in SQL are sent to the server using that communcation protocol and the results of the queries are then returned through that protocol (in a DBMS independent way).

There seems to be a blurry line between the communication protocol and the queries as the JDBC API also specifies calls to retrieve meta data from the server (or from the result). But actually the driver is free to use any means of transportation that deems suitable. That does not necessarily need to be a SQL query.

JDBC is an abstraction layer for RDBMS.

Unfortunately, as you already recognized in your question, the abstraction is leaky.

If you stick to the small subset of SQL and Metadata that is common to all RDBMS, you'll be fine. However in reality, you're very likely to quickly outgrow these limits.

JDBC works as an abstraction of an RDBMS approximately to the same degree SQL does: basic queries are compatible enough, but you constantly bump into requirements that can only be implemented using vendor-specific features:

  • autoincrementing columns
  • paging
  • internationalization
  • etc.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!