Documentation

The Java™ Tutorials
Hide TOC
JDBC ArchitectureJDBC体系结构
Trail: JDBC Database AccessJDBC数据库访问
Lesson: JDBC IntroductionJDBC简介

JDBC Architecture

The JDBC API supports both two-tier and three-tier processing models for database access.JDBCAPI支持数据库访问的两层和三层处理模型。

Figure 1: Two-tier Architecture for Data Access.图1:数据访问的两层体系结构。


The DBMS-proprietary protocol provides two-way communication between the client machine and the database server

In the two-tier model, a Java applet or application talks directly to the data source.在两层模型中,Java小程序或应用程序直接与数据源对话。This requires a JDBC driver that can communicate with the particular data source being accessed.这需要一个JDBC驱动程序,它可以与正在访问的特定数据源通信。A user's commands are delivered to the database or other data source, and the results of those statements are sent back to the user.用户的命令被发送到数据库或其他数据源,这些语句的结果被发送回用户。The data source may be located on another machine to which the user is connected via a network.数据源可以位于用户通过网络连接到的另一台机器上。This is referred to as a client/server configuration, with the user's machine as the client, and the machine housing the data source as the server.这称为客户机/服务器配置,用户的机器作为客户机,容纳数据源的机器作为服务器。The network can be an intranet, which, for example, connects employees within a corporation, or it can be the Internet.网络可以是内部网,例如,它连接公司内的员工,也可以是互联网。

In the three-tier model, commands are sent to a "middle tier" of services, which then sends the commands to the data source.在三层模型中,命令被发送到服务的“中间层”,然后服务将命令发送到数据源。The data source processes the commands and sends the results back to the middle tier, which then sends them to the user.数据源处理命令并将结果发送回中间层,中间层随后将它们发送给用户。MIS directors find the three-tier model very attractive because the middle tier makes it possible to maintain control over access and the kinds of updates that can be made to corporate data.MIS主管发现三层模型非常有吸引力,因为中间层可以保持对访问的控制以及对公司数据的更新。Another advantage is that it simplifies the deployment of applications.另一个优点是它简化了应用程序的部署。Finally, in many cases, the three-tier architecture can provide performance advantages.最后,在许多情况下,三层体系结构可以提供性能优势。

Figure 2: Three-tier Architecture for Data Access.图2:数据访问的三层体系结构。


The DBMS-proprietary protocol provides two-way communication between the database server and the server machine. HTTP, RMI, CORBA or other calls provide two way communication between the server machine and the client machine

Until recently, the middle tier has often been written in languages such as C or C++, which offer fast performance.直到最近,中间层通常用C语言或C++语言编写,提供快速的性能。However, with the introduction of optimizing compilers that translate Java bytecode into efficient machine-specific code and technologies such as Enterprise JavaBeans™, the Java platform is fast becoming the standard platform for middle-tier development.然而,随着将Java字节码转换为高效的机器特定代码和技术(如Enterprise JavaBeans™)的优化编译器的引入,Java平台正迅速成为中间层开发的标准平台。This is a big plus, making it possible to take advantage of Java's robustness, multithreading, and security features.这是一个巨大的优势,使利用Java的健壮性、多线程和安全特性成为可能。

With enterprises increasingly using the Java programming language for writing server code, the JDBC API is being used more and more in the middle tier of a three-tier architecture.随着企业越来越多地使用java编程语言编写服务器代码,JDBC API越来越多地应用于三层体系结构的中间层。Some of the features that make JDBC a server technology are its support for connection pooling, distributed transactions, and disconnected rowsets.使JDBC成为服务器技术的一些特性是它支持连接池、分布式事务和断开连接的行集。The JDBC API is also what allows access to a data source from a Java middle tier.JDBCAPI还允许从Java中间层访问数据源。


Previous page: JDBC Introduction
Next page: A Relational Database Overview