计算机应用

• 软件技术与典型应用 • 上一篇    下一篇

基于模板方法的JDBC API的抽象封装与实现

刘泉 赵晓明   

  1. 武汉理工大学
  • 收稿日期:2006-03-10 修回日期:1900-01-01 出版日期:2006-09-01 发布日期:2006-09-01
  • 通讯作者: 赵晓明

Wrapping JDBC API with template method pattern

<a href="http://www.joca.cn/EN/article/advancedSearchResult.do?searchSQL=((([Author]) AND 1[Journal]) AND year[Order])" target="_blank"></a> <a href="http://www.joca.cn/EN/article/advancedSearchResult.do?searchSQL=((([Author]) AND 1[Journal]) AND year[Order])" target="_blank"></a> <a href="http://www.joca.cn/EN/article/advancedSearchResult.do?searchSQL=((([Author]) AND 1[Journal]) AND year[Order])" target="_blank"></a>   

  • Received:2006-03-10 Revised:1900-01-01 Online:2006-09-01 Published:2006-09-01

摘要: 作为访问关系数据库的核心标准,JDBC在Java平台的应用上发挥着至关重要的作用,然而它自身的不足增加了直接基于JDBC API应用的复杂度。分析了直接采用JDBC API访问数据库的相关问题,并利用模板方法和回调函数对API进行抽象封装,且给出了相应的实现,最后比较了直接采用JDBC API和对API进行封装后的性能差异,证明该封装与实现是一个良好的实践模型。

关键词: 模板方法, 回调函数, Java, JDBC

Abstract: As a standard core specification to access relational database, JDBC(Java Database Connectivity) plays an important role in the Java platform applications. However, due to its own deficiency, complexities are introduced into the applications directly based on JDBC API(Application Programming Interface). Some related issues when using JDBC API to access database were discussed, and template method and callback functions were adopted to wrap and implement API. Then, the performances between using JDBC API directly and using wrapped API were compared. It is proved that the latter approach has better performance in application.

Key words: template method, callback function, Java, JDBC