即时消息系统中基于JDBC的中界应用外文翻译资料

 2022-12-19 17:18:58

JDBC-based Middleware Applications in Instant Message Systems

Yi Zhang, Lu-yong Zhang

Key Laboratory of Universal Wireless Communications, Ministry of Education Beijing University of Posts and Telecommunications

Beijing 100876, China

1.JDBC drivers

JDBC drivers are divided into four types according to different technologies to access the database. Different types of drivers have different characteristics and utilities. The JDBC driver layer is located between the JDBC Driver Manager and the Database Driver layer.The first category: JDBC-ODBC (Open Database Connectivity) Bridge driver. In this method, JDBC only needs to connect to ODBC, which helps JDBC connect to any database that ODBC supports. This type of driver consists of the JDBC-ODBC Bridge and the ODBC driver. Since most database systems have ODBC drivers, Java programs can access to databases such as Oracle, Sybase, SQL Server, etc. The driver has been included in the sun.jdbc.odbc package of Java2SDK. This type of driver needs to install native code libraries, which rely on local programs, therefore portability is poor. Its working principle is that JDBC calls the transform into ODBC calls through some local code, and then an ODBC driver is used to communicate with the database. This type must install the ODBC driver on the local computer, and then JDBC API commands used in the java program transform into ODBC API commands through the conversion of the JDBC- ODBC Bridge, and finally the ODBC driver calls the local database driver code to accomplish the access to the local database. However, since JDBC-ODBC calls ODBC first, and then ODBC calls the local database interface to access the database, the efficiency is relatively low, which is inappropriate for the applications of accessing large amounts of data .

The second category: the local JDBC API driver. This driver is made up of part of the Java program and part of the local code, and it is used for communicating with the database client-side API. Such drivers must first install specific drivers on the local computer (like ODBC), then JDBC API in the Java program transforms into the local API through the conversion of the Java JDBC Driver in order to access the database. This driver works more efficient than the JDBC-ODBC Bridge mode. However, it still needs to load code libraries on the client, which is not suitable for Internet-based applications. Using the local API-driven method, the specific driver name and the url are set in the JDBC code. Different drivers and different databases should use different driver names and the url.

The third category: the pure Java database middleware driver. When using this type of driver, there is no need to install any additional software on the local computer, but the middleware must be installed on the database management system server. The middleware is responsible for all the necessary conversions when accessing the database. Its working principle is:

JDBC first passes the requests of accessing the database to the middleware server on the network. The middleware server then transforms requests into database-specific access instructions, and then this call is sent to the database server in order to complete the operation of the database. The middleware server can support the access to multiple databases. This method does not require the client to load the database vendorrsquo;s code libraries, one single driver can access multiple databases, which represents the good scalability. Such drivers use standard network protocols and are supported by firewalls, which is an ideal choice for developing the Applet program and for Internet applications. It is widely used in the development of Web-based applications because of its better function and security. However, this driver in the middleware layer still needs to configure other database drivers, as a result, the middle-tier data transmission affects the efficiency.

The fourth category: the pure Java JDBC driver. Such

drivers are pure Java drivers facing directly to the database, which achieve the platform independence. This type of driver includes the access protocol in a particular database, drivers use Socket, so that the client can communicate with the database directly. There is no need to install any additional software when using this type of drivers (either the local computer or the database server), all operations of accessing to the database are directly completed by the JDBC driver. These drivers can transform JDBC calls into the DBMS-specific network protocol, identify the specific database under network protocols automatically and directly create the data connection. Since this driver does not need to first pass JDBC calls to ODBC or to the local database interface or to a middle-tier server, so the efficiency is very high, the accessing speed is the fastest, and the security is also very good. Moreover, this method does not require a client or a server-side to load any software or drivers, it is the most direct way to achieve Java. However, this driver also has its shortcomings. Due to the use of DBMS-specific network protocols, it may not be supported by firewalls, which causes a potential Internet security risk. Secondly, since different DBMS have different drivers, therefore in a heterogeneous computing environment, the number of drivers may be huge. However, this driver has the highest efficiency and has the best compatibility .

The comparison of several JDBC drivers:

From the perspective of the amount of the data manipulation, the JDBC-ODBC driver should be considered

first for the Windows environment development systems or the application of a small amount of the data manipulation.

From the efficiency perspective, the third and the fourth class driver are much better than the first and the second one, therefore the third and the fourth class driver should be considered first.<!--

剩余内容已隐藏,支付完成后下载完整资料


即时消息系统中基于JDBC的中界应用

Yi Zhang, Lu-yong Zhang

基于JDBC的中间件在即时消息系统中的应用

教育部北京邮电大学通用无线通信重点实验室

  1. JDBC 驱动

JDBC驱动程序根据不同的技术分为四种类型来访问数据库。不同类型的驱动程序具有不同的特性和实用性。JDBC驱动程序层位于JDBC驱动程序管理器和数据库驱动程序层之间。

第一类:JDBC-ODBC(开放数据库连接)网桥驱动程序。在这个方法中,JDBC只需要连接到ODBC,这有助于JDBC连接到任何ODBC支持的数据库。这种类型的驱动程序由JDBC-ODBC桥和ODBC驱动程序组成。由于大多数数据库系统都有ODBC驱动程序,Java程序可以访问诸如Oracle、Sybase、SQL Server等数据库。这类驱动程序需要安装依赖本地程序的本机代码库,因此可移植性较差。其工作原理是JDBC通过一些本地代码调用转换成ODBC调用,然后使用一个ODBC驱动程序与数据库通信。该类型必须在本地计算机上安装ODBC驱动程序,然后通过JDBC-ODBC桥的转换将Java程序中使用的JDBC API命令转换成ODBC API命令,最后ODBC驱动程序调用本地数据库驱动程序代码来完成对本地数据库的访问。但是,由于JDBC-ODBC首先调用了ODBC,然后又调用了本地数据库接口来访问数据库,所以效率相对较低,不适合于访问大量数据的应用。

第二类:本地JDBCAPI驱动程序。该驱动程序由Java程序的一部分和本地代码的一部分组成,用于与数据库客户端API进行通信。这样的驱动程序必须首先在本地计算机上安装特定的驱动程序(如ODBC),然后Java程序中的JDBC API通过JavaJDBC驱动程序的转换将其转换为本地API,以便访问数据库。这个驱动程序比JDBC-ODBCBridge模式更有效。但是,它仍然需要在客户机上加载代码库,这不适用于基于Internet的应用程序。使用本地API驱动的方法,在JDBC代码中设置特定的驱动程序名称和URL。不同的驱动程序和不同的数据库应该使用不同的驱动程序名和URL。

第三类:纯Java数据库中间件驱动程序。使用这种类型的驱动程序时,不需要在本地计算机上安装任何额外的软件,但是中间件必须安装在数据库管理系统服务器上。中间件负责在访问数据库时进行所有必要的转换。其工作原理是:

JDBC首先将访问数据库的请求传递给网络上的中间件服务器。然后中间件服务器将请求转换为特定于数据库的访问指令,然后将此调用发送到数据库服务器,以完成数据库的操作。中间件服务器可以支持对多个数据库的访问。该方法不需要客户机加载数据库供应商的代码库,一个驱动程序可以访问多个数据库,具有良好的可扩展性。这些驱动程序使用标准网络协议,并受防火墙支持,这是开发小程序和Internet应用程序的理想选择。由于其良好的功能和安全性,在基于Web的应用程序开发中得到了广泛的应用。但是,中间件层中的这个驱动程序仍然需要配置其他数据库驱动程序,因此中间层数据传输会影响效率。

第四类:纯Java JDBC驱动程序。这样驱动程序是面向数据库的纯Java驱动程序,实现了平台的独立性。这种类型的驱动程序包括特定数据库中的访问协议,驱动程序使用套接字,这样客户机就可以直接与数据库通信。在使用这种类型的驱动程序(本地计算机或数据库服务器)时,不需要安装任何其他软件,所有访问数据库的操作都由JDBC驱动程序直接完成。这些驱动程序可以将JDBC调用转换成DBMS特定的网络协议,自动识别网络协议下的特定数据库,并直接创建数据连接。由于该驱动程序不需要先将JDBC调用传递到ODBC、本地数据库接口或中间层服务器,所以效率很高,访问速度最快,安全性也很好。此外,该方法不需要客户端或服务器端加载任何软件或驱动程序,它是实现Java最直接的方式。然而,这个驱动程序也有其缺点。由于使用了DBMS特定的网络协议,防火墙可能不支持它,这会造成潜在的Internet安全风险。其次,由于不同的DBMS具有不同的驱动程序,因此在异构计算环境中,驱动程序的数量可能很大。但是,这个驱动程序具有最高的效率和最佳的兼容性。

几种JDBC驱动程序的比较:

从数据操作的数量来看,应该考虑JDBC-ODBC驱动程序

首先为windows环境开发系统或应用少量的数据操作。

从效率的角度看,三、四级驾驶员要比一、二级驾驶员好得多,所以三、四级驾驶员要优先考虑。

从互联网应用的角度来看,只能考虑三级和四级驱动。第三类驱动程序可以在中间层配置多种数据库服务器驱动程序,适用于同时连接多个数据库的需要,也适用于需要高并发连接的应用程序。

从客户机部署的角度来看,JDBC-ODBC桥驱动程序需要在客户机上安装ODBC驱动程序。对于本地API驱动程序,供应商需要在客户机上安装客户机库。后两种类型相对简单。

  1. JDBC连接池

为了解决由于大量数据访问而导致的效率问题,可以考虑使用连接池方法。

JDBC连接池基于配置在一个项目中指向不同的数据库,实现了分布式数据存储。因此,与背景的交互更为有效。JDBC连接池可以定义数据库连接的最大(最小)数量、数据超时等。

连接池可视为连接对象的“存储池”,连接池预先建立一些连接,并存储在存储池中供用户使用。连接池通过其内部连接机制控制连接对象编号,并为每个子查询提供访问连接的接口。

连接池由三个主要组件组成,即线程池、连接池和数据库操作。线程池实现了对每个子查询的线程调度,以合理利用计算机的内部线程资源。连接池负责创建、管理和释放存储池中的连接。连接池提前在存储池中建立了一些连接,当用户的数据访问需求分解为多个子查询时,通过线程池调度,每个子查询从连接池中获取一个已建立的自由对象,用于建立与数据库的连接。使用后,用户将连接放回下一个用户的连接池,而不是关闭连接。数据库操作负责实现子查询、返回子查询结果和处理异常。连接池可以避免频繁的数据库建立或关闭连接的开销,大大提高了程序的效率。同时,数据库连接的数量和使用也可以由它自己的管理机制来监控。

现在,名为connection pool的连接池用于实现连接。

ConnectionPool的基本属性:

m_connectionpoolsize:池连接中的最小连接数;

m_connectionpoolmax:池连接中的最大连接数;

m_connectionusecount:连接的最大使用数;

M_connectionTimeout:连接的最长空闲时间;

m_maxconnections=-1:同时连接的最大数目;

MimTime:计时器。

这些属性为连接池中的每个连接定义有效的状态值。实际上,连接池的自我管理是根据对状态和每个连接的数量的及时判断来运行的。

ConnectionPool完成管理所需的基本接口定义如下:

通过这些接口,连接池的基本管理已经完成。

剩余内容已隐藏,支付完成后下载完整资料


资料编号:[19925],资料为PDF文档或Word文档,PDF文档可免费转换为Word

原文和译文剩余内容已隐藏,您需要先支付 30元 才能查看原文和译文全部内容!立即支付

以上是毕业论文外文翻译,课题毕业论文、任务书、文献综述、开题报告、程序设计、图纸设计等资料可联系客服协助查找。