jdbc驱动程序类型

A JDBC Driver is a software component, which allows a Java application to interact with a database. With a JDBC driver, an application is made capable of sending queries to a database and receiving results.

JDBC驱动程序是一个软件组件,它允许Java应用程序与数据库进行交互。 使用JDBC驱动程序,使应用程序能够向数据库发送查询并接收结果。

In this lesson, we will try to answer some simple but important questions related to these jdbc drivers like how they do what they do, how many types of drivers are there, etc. JDBC stands for Java DataBase Connectivity.

在本课中,我们将尝试回答一些与这些jdbc驱动程序有关的简单但重要的问题,例如它们的工作方式,驱动程序的类型等等。JDBC代表Java DataBase Connectivity。

JDBC驱动程序如何工作? (How does JDBC driver works?)

The Java JDBC API (Application Programming Interface) is a set of interfaces built upon the JavaSoft specification. These interfaces consist of a set of contract (or abstract) methods which its implementations must agree to, or must implement to conform to it. What this means is, the JDBC drivers are actually a set of classes that implement these interfaces.

Java JDBC API(应用程序编程接口)是一组基于JavaSoft规范构建的接口 。 这些接口由一组合同(或抽象)方法组成,其实现必须同意或必须实现才能与之兼容。 这意味着JDBC驱动程序实际上是实现这些接口的一组类。

As JDBC drivers follow the JavaSoft specification, they can virtually access any Database, execute commands with Spreadsheets and even some flat file formats! The only condition is that a JDBC driver must exist for that SQL based database.

当JDBC驱动程序遵循JavaSoft规范时,它们实际上可以访问任何数据库,使用电子表格甚至某些平面文件格式执行命令! 唯一的条件是该基于SQL的数据库必须存在JDBC驱动程序。

JDBC驱动程序类型 (JDBC Driver Types)

In this section, we will explore the types of JDBC drivers. But wait! Didn’t we say that JDBC follows a specification, still there are multiple types? Yes, a specification just informs what should be done and not how it should be done.

在本节中,我们将探讨JDBC驱动程序的类型。 可是等等! 我们不是说JDBC遵循规范,还是有多种类型吗? 是的,规范只是告知应该做什么,而不是应该怎么做。

Overall, JDBC driver types are used to categorize the technology used to connect to the database. Let’s see each of them here.

总体而言,JDBC驱动程序类型用于对用于连接数据库的技术进行分类。 让我们在这里看到他们每个人。

  1. 类型1 –桥驱动器 (Type 1 – Bridge Drivers)

Type 1 drivers are termed as Bridge Drivers. These bridge drivers translate all JDBC query calls into ODBC calls. This is an advantage as many drivers exist for the Open Database Connectivity (ODBC) technology which means, Type 1 drivers exist for all those databases as well.

类型1驱动程序称为网桥驱动程序。 这些桥驱动程序将所有JDBC查询调用转换为ODBC调用。 这是一个优点,因为开放数据库连接(ODBC)技术存在许多驱动程序,这意味着所有这些数据库也都具有Type 1驱动程序。

Due to following disadvantages, Type 1 Driver is rarely used in production applications:

由于以下缺点,类型1驱动程序很少在生产应用中使用:

  • Queries are slow as they need to go through ODBC conversion followed by native DB conversions.查询速度很慢,因为它们需要先进行ODBC转换,然后再进行本机DB转换。
  • Bridge driver must be installed on host application which may not always be possible.桥驱动程序必须安装在主机应用程序上,但并非总是可能的。
  1. 类型2 –本机API (Type 2 – Native API)

Type 2 Drivers are termed as Native Drivers. These native drivers translate all JDBC calls into native API database calls. Type 2 drivers are faster than Type 1 Bridge drivers as conversion happens directly to DB operations. This API isn’t completely written in Java as it access Native Database code as well.

类型2驱动程序称为本机驱动程序。 这些本机驱动程序将所有JDBC调用转换为本机API数据库调用。 类型2驱动程序比类型1桥驱动程序更快,因为转换直接发生在数据库操作中。 该API并非完全用Java编写的,因为它也可以访问本机数据库代码。

Due to following disadvantages, Type 2 Drivers are rarely used in production applications:

由于以下缺点,Type 2驱动程序很少在生产应用中使用:

  • Client-side library for a Database has to be installed which may not always be possible.必须安装数据库的客户端库,但这并非总是可能的。
  • Not many database vendors provide native Client-side library.没有多少数据库供应商提供本机客户端库。
  1. 类型3 –网络协议 (Type 3 – Network Protocol)

Type 3 Drivers are termed as Network Protocol or Middleware Drivers. These Network Protocol drivers translate all JDBC calls into database-specific calls. If a Java application needs to access multiple types of databases at the same time, type 3 is the preferred driver.

类型3驱动程序称为网络协议或中间件驱动程序。 这些网络协议驱动程序将所有JDBC调用转换为特定于数据库的调用。 如果Java应用程序需要同时访问多种类型的数据库,则类型3是首选驱动程序。

Type 3 Drivers are most used drivers in production applications due to following advantages:

由于以下优点,类型3驱动程序是生产应用程序中最常用的驱动程序:

  • Type 3 JDBC drivers are the most flexible JDBC driver as they don’t need any native binary code on the client machine.Type 3 JDBC驱动程序是最灵活的JDBC驱动程序,因为它们在客户端计算机上不需要任何本机二进制代码。
  • The middleware application can do many other things apart from JDBC logic like Caching, Load balancing on Database servers etc. which is an overall performance boost for any JEE application.中间件应用程序除了可以执行JDBC逻辑(如缓存,数据库服务器上的负载平衡等)外,还可以做很多其他事情,这可以提高所有JEE应用程序的性能。

Type 3 Driver does have some disadvantages as well:

Type 3驱动程序确实也有一些缺点:

  • The middleware tier of the application needs some Database specific coding as well. This is usually an accepted solution due to the flexibility it offers.应用程序的中间件层也需要一些特定于数据库的编码。 由于它提供的灵活性,通常是一种公认​​的解决方案。
  • The middleware application may add a latency. But that can be improved by better coding standards etc.中间件应用程序可能会增加延迟。 但这可以通过更好的编码标准等来改善。

Also, the driver manager class is a fully implemented class which connects an application to a data source, which is specified by a database URL.

同样,驱动程序管理器类是完全实现的类,它将应用程序连接到由数据库URL指定的数据源。

  1. 类型4 –本机协议 (Type 4 – Native Protocol)

Type 4 Drivers are termed as Native Protocol or Middleware Drivers. These Native Protocol drivers translate all JDBC calls into direct vendor-specific database calls. The type 4 driver is written purely in Java and is platform independent.

类型4驱动程序称为本机协议或中间件驱动程序。 这些本机协议驱动程序将所有JDBC调用转换为直接的特定于供应商的数据库调用。 Type 4驱动程序完全用Java编写,并且与平台无关。

Type 4 Drivers has a great advantage of it doesn’t needing any middleware application. Thus the performance is considerably improved. But Drivers are database specific and so, all vendors might not provide Type 4 driver for its usage.

Type 4驱动程序具有很大的优势,因为它不需要任何中间件应用程序。 因此,性能大大提高。 但是驱动程序是特定于数据库的,因此,所有供应商都可能不提供Type 4驱动程序来使用。

如何确定用于JDBC的驱动程序? (How to determine which driver to use for JDBC?)

We need to decide this based on the Database that we use in our application.

我们需要根据我们在应用程序中使用的数据库来决定这一点。

For example:

例如:

  • In case of MySQL, we need to use jdbc driver for MySQL provided here.如果是MySQL,我们需要使用此处提供MySQL的jdbc驱动程序。
  • If case of Oracle, we can use jdbc driver provided by Oracle.here.如果是Oracle,我们可以使用Oracle提供的jdbc驱动程序。 在这里 。

You can find JDBC drivers on the chosen DB’s official website. It is dependent on the JDK version as well as DB version.

您可以在所选数据库的官方网站上找到JDBC驱动程序。 它取决于JDK版本以及DB版本。

结论 (Conclusion)

In this lesson, we categorised 4 kinds of JDBC drives and looked at their advantages and disadvantages along with reasons to use them in production-grade web applications.

在本课程中,我们对4种JDBC驱动器进行了分类,并研究了它们的优缺点以及在生产级Web应用程序中使用它们的原因。

Feel free to share your views in comments below.

随时在下面的评论中分享您的观点。

翻译自: https://www.journaldev.com/17060/jdbc-driver-types

jdbc驱动程序类型

jdbc驱动程序类型_JDBC驱动程序类型相关推荐

  1. java驱动包是什么_JDBC驱动程序有4种类型是什么

    JDBC驱动程序有4种类型是什么 发布时间:2020-10-20 17:28:28 来源:亿速云 阅读:78 作者:小新 这篇文章主要介绍JDBC驱动程序有4种类型是什么,文中介绍的非常详细,具有一定 ...

  2. ODBC、JDBC和四种驱动类型

    早期的数据库开发领域没有通用的应用程序编程接口,开发人员在使用不同数据库产品时,必须学习和使用厂商专用API,例如Oracle Call Interface.Microsoft Database Li ...

  3. 数据库字段类型、JDBC类型、Java类型映射关系

    数据库字段类型:指的就是数据库字段设置的类型. JDBC类型:java database connector的缩写. 不同的数据库为了能让Java 程序链接并使用数据库, 各个数据库厂商自己提供的驱动 ...

  4. 详解JDBC的四种驱动类型

    原文地址:http://www.yiidian.com/jdbc/jdbc-connection-driver.html JDBC驱动程序是一个软件组件,JDBC使得Java应用程序可以与数据库进行交 ...

  5. java和jdbc对应关系,JDBC类型与JAVA类型对应关系

    最近在做代码生成工具,通过数据库表生成代码半成品,其中就有JDBC类型与JAVA类型对应的问题. 我的做法看看别人是怎么对应的,JDBC驱动里面一定有,我们就postgresql数据,通过搜索解压后的 ...

  6. Java JDBC中,MySQL字段类型到JAVA类型的转换

    转载自:https://www.cnblogs.com/waterystone/p/6226356.html 1. 概述 在使用Java JDBC时,你是否有过这样的疑问:MySQL里的数据类型到底该 ...

  7. JDBC连接数据库遇到的“驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。”问题解决方法

    JDBC连接数据库遇到的"驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接."问题解决方法! 时间:2018-12-20 本文章向大家介绍JDB ...

  8. JDBC:PreparedStatement 插入BLOB类型的数据,PreparedStatement 批量处理,Connection 事务处理

    JDBC:PreparedStatement 插入BLOB类型的数据,PreparedStatement 批量处理,Connection 事务处理 每博一文案 村上春树说: 你要做一个不动声色的大人了 ...

  9. java jdbc 详解_JDBC详解

    1.JDBC(Java Database Connection):java连接数据库统一接口API,底层主要通过直接的JDBC驱动和 JDBC-ODBC桥驱动实现与数据库的连接. 1>.JDBC ...

最新文章

  1. 创建一个好的Sprint Backlog 的8个小贴士
  2. 算法炒房三月亏20多亿。房地产巨头大翻车:房价水太深,AI根本把握不住
  3. 激光SLAM学习--数据处理和特征提取
  4. java不带package和带package的编译方式
  5. JEMTER简单的测试计划
  6. RTOS原理与实现09:事件标志组实现
  7. spring ,springmvc的常用标签注解
  8. 03、三种简单的计时器
  9. 代码调试技巧【OI缩水版】
  10. wxpython多线程 假死_wxpython多线程防假死与线程间传递消息实例详解
  11. C++中 _T 的用途
  12. [4G5G专题-49]:物理层-为什么从事计算机领域的人,学习无线通信那么难?从物理层信号处理看无线通信思维领域的切换与跨越。
  13. 统计学_显著性检验综述
  14. Accuracy(精度)、Precision(精准度)和Recall(召回率)
  15. linux运维经验总结
  16. 名帖121 文徵明 小楷《琴赋》
  17. 图片内,笔迹轨迹识别
  18. 51单片机(四).C51编程语言
  19. 手把手教你通过端口映射,轻松搭建Windows远程桌面
  20. 深度|从一个故事说起,谈谈企业应用架构的演变史

热门文章

  1. 亲和数[HDU2040]
  2. bash中符号那点事
  3. [转载] Python使用list.reverse()返回None
  4. [转载] python histogram函数_Python numpy.histogram_bin_edges函数方法的使用
  5. Django之模板层
  6. AJAX通过HTML请求C#一般处理程序
  7. js返回上级页面的方法(亲测)
  8. Android中GridView实现互相添加和删除
  9. 基于c的xml文件解析(转)
  10. 使用Java Mail接收 Gmail 电子邮件