| 网站首页 | JAVA文章 | AppServers | Web开发 | 应用开发 | 资源下载 | 论坛
    想学好编程,学好外语很重要  [enadd  2006年12月25日]        
设为首页 加入收藏 联系站长
您现在的位置: 编程笔记网 >> JAVA文章 >> 数据库 >> 文章正文
使用PreparedStatement为不同的数据库编写可移植的数据库存取方?        【字体:
使用PreparedStatement为不同的数据库编写可移植的数据库存取方?
作者:佚名    文章来源:不详    点击数:    更新时间:2006-4-16

服务端的Web application经常需要读取后端的数据库,一些设计良好、高效的数据库存取方法可以大大降低代码的可维护性,从而提升自身应用的复杂性,JDBC的PreparedStatement接口和它的setObject()方法可以帮助你实现
快速、通用的数据库访问方法,应用在任何数据库服务器上。

Java has become increasingly popular as a server-side programming language for database-powered Web applications. Those applications´ business logic-handling methods must work with data from backend databases. Therefore, you need a set of well-designed database access methods. Those access methods should meet the following requirements:

They should be generic for any table schema. Users can supply the actual table schema information at runtime. Genericness lets you reuse the methods throughout the application to reduce code maintenance overhead and minimize chances for human errors. Genericness also lets you easily add new tables or change existing schema, therefore, making the application more expandable and flexible.

They should be portable across different database servers so the Web application can deploy independent of the backend. Java´s built-in, cross-operating system portability no longer suffices for Web applications.

They should be optimized for speed.

Java现已成为服务端web应用的主要编程语言,几乎所有的商业逻辑都离不开后端数据库的支持,因此,你需要一系列设计良好的数据库访问方法。这些方法需要满足以下一些要求:

对所有的表schema具有通用性,可以在运行时动态地应用某一种形式,这种通用性降低了方法在整个应用中的维护量并最小化人为失误。这种通用性也可以使你任意的增加新的表schema或改变现有的表schema,提高应用的扩展性

它们可以被应用于多种数据库服务器上从而使你的web应用可以独立于后端的数据库,Java的跨平台对web应用还不够,好的应用还需要有多数据库的适应性。还应调整他们的速度性能


In this tip, I discuss how to write generic, portable, and fast database access methods. To illustrate, I provide example code to access an imaginary database table called Article (see Article.sql), which has several fields with different types.


在本文中,我们讨论如何编写通用、可移植、高效的数据库访问方法,为了阐述清楚,我们用实例代码对一个假想数据库表Article进行操作(见Article.sql),该表中有几个不同类型的字段

[1] [2] [3] [4] [5] [6] [7] 下一页  

文章录入:enadd    责任编辑:enadd 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
  • jsp连接数据库大全

  • RESIN/TOMCAT和MYSQL的连接解…

  • JSP数据库连接池的必要性

  • 通过JDBC连接oracle数据库的…

  • Tomcat4的数据库连接池配置

  • 数据库连接池Java实现小结

  • 用连接池提高Servlet访问数据…

  • JSP数据库连接大全

  • JSP数据库操作例程

  • 利用weblogic的POOL(连接池…

  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 管理登录 |