gpt4 book ai didi

jdbc - jdbc 是如何工作的

转载 作者:太空狗 更新时间:2023-10-30 01:43:09 26 4
gpt4 key购买 nike

谁能告诉我 jdbc 是如何工作的?它如何设法与 DBMS 通信?因为 DBMS 可能是用其他编程语言编写的。

最佳答案

与数据库的通信由 JDBC 驱动程序处理,这些驱动程序可以使用各种策略与数据库“对话”(从“翻译”到使用“本地”语言)。根据使用的策略,驱动程序分为 4 种类型。 Types of JDBC technology drivers对它们中的每一个都提供一个很好的描述:

  1. A JDBC-ODBC bridge provides JDBC API access via one or more ODBC drivers. Note that some ODBC native code and in many cases native database client code must be loaded on each client machine that uses this type of driver. Hence, this kind of driver is generally most appropriate when automatic installation and downloading of a Java technology application is not important. For information on the JDBC-ODBC bridge driver provided by Sun, see JDBC-ODBC Bridge Driver.

  2. A native-API partly Java technology-enabled driver converts JDBC calls into calls on the client API for Oracle, Sybase, Informix, DB2, or other DBMS. Note that, like the bridge driver, this style of driver requires that some binary code be loaded on each client machine.

  3. A net-protocol fully Java technology-enabled driver translates JDBC API calls into a DBMS-independent net protocol which is then translated to a DBMS protocol by a server. This net server middleware is able to connect all of its Java technology-based clients to many different databases. The specific protocol used depends on the vendor. In general, this is the most flexible JDBC API alternative. It is likely that all vendors of this solution will provide products suitable for Intranet use. In order for these products to also support Internet access they must handle the additional requirements for security, access through firewalls, etc., that the Web imposes. Several vendors are adding JDBC technology-based drivers to their existing database middleware products.

  4. A native-protocol fully Java technology-enabled driver converts JDBC technology calls into the network protocol used by DBMSs directly. This allows a direct call from the client machine to the DBMS server and is a practical solution for Intranet access. Since many of these protocols are proprietary the database vendors themselves will be the primary source for this style of driver. Several database vendors have these in progress.

正如我们所见,有多种策略可以实现互操作性,包括在 Java 中实现给定数据库使用的网络协议(protocol)(类型 4)。由于它们易于使用(无需安装额外的东西,没有 JNI)和良好的性能(它们现在的性能与类型 2 驱动程序一样好),类型 4 实际上是当今最常用的。

关于jdbc - jdbc 是如何工作的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2716733/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com