[企业管理] struts+dao的设计模式

[复制链接]
发表于 2022-9-23 16:58:01
DAO(DataAccessObject)的设计模式是J2EE中主要的设计模式.选用DAO的设计的好处:用户不需求认识底层的详细终结,只需求操作接口;一起终结了前台和后后台的分别;(DAO中只需求操作对象);有利于代码的重用.(假如用户需求增加新的功能时候,我只需求在DAO这接口中增加的笼统的方法,然后在DAOImpl中终结用户所增加的功能,就能很好的终结增加用户功能的.)DAO的整体设计过程:JSP---gt;DAO工厂--gt;详细终结类--gt;终结数据库的详细操作1.终结数据库的连接类(DataBaseConnection.java)packageorg.zhao.DataBaseConnection.dbc;importjava.sql.
;publicclassDataBaseConnection{privatefinalStringDBDRIVER=com.mysql.jdbc.Driver;privatefinalStringDBURL=jdbc:mysql://localH/OST:3306/student;privatefinalStringDBUSER=root;privatefinalStringDBPASSWORD=root;privateConnectionconn=null;publicDataBaseConnection(){try{Class.forName(DBDRIVER);//conn=DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD);conn=DriverManager.getConnection(jdbc:mysql://localH/OST:3306/student?user=rootpassword=root);}catch(Exceptione){}}publicConnectiongetConnection(){returnthis.conn;}publicvoidclose(){try{this.conn.close();}catch(SQLExceptione){e.printStackTrace();}}}2.定义项目所要终结的功能......
struts+dao的设计模式.txt

(The design pattern of DAO (DataAccessObject) is the main design pattern in J2EE. The advantages of choosing DAO design: users do not need to know the detailed termination of the underlying layer, but only need to operate the interface; the distinction between the foreground and the background is terminated together; (in DAO only Requirement operation object); it is conducive to code reuse. (If the user needs to add new functions, I only need the general methods added in the DAO interface, and then terminate the user-added functions in DAOImpl, it will be very good. The terminal of the terminal increases user functions.) The overall design process of DAO: JSP---gt; DAO factory --gt; detailed terminal class --gt; detailed operation of terminal database 1. Terminal database connection class (DataBaseConnection.java) packageorg.zhao.DataBaseConnection.dbc;importjava.sql.
;publicclassDataBaseConnection{privatefinalStringDBDRIVER=com.mysql.jdbc.Driver;privatefinalStringDBURL=jdbc:mysql://localH/OST:3306/student;privatefinalStringDBUSER=root;privatefinalStringDBPASSWORD=root;privateConnectionconn=null;publicDataBaseConnection(){try{Class.forName (DBDRIVER);//conn=DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD);conn=DriverManager.getConnection(jdbc:mysql://localH/OST:3306/student?user=rootpassword=root);}catch(Exceptione ){}}publicConnectiongetConnection(){returnthis.conn;}publicvoidclose(){try{this.conn.close();}catch(SQLExceptione){e.printStackTrace();}}}2. Define the function to be terminated by the project ......
The design pattern of struts dao.txt)

[下载]16580273690.rar




上一篇:java线程技术O‘reilly出版 第2版
下一篇:IT常用日语词语汇总

使用道具 举报

Archiver|手机版|小黑屋|吾爱开源 |网站地图

Copyright 2011 - 2012 Lnqq.NET.All Rights Reserved( ICP备案粤ICP备14042591号-1粤ICP14042591号 )

关于本站 - 版权申明 - 侵删联系 - Ln Studio! - 广告联系

本站资源来自互联网,仅供用户测试使用,相关版权归原作者所有

快速回复 返回顶部 返回列表