




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
SQL文本SQL配置好代碼的注釋,注意注釋的編寫,另外加上javaDoc文檔,如果當(dāng)前項目采用的編碼方式是否合理,如果不合理進(jìn) -encodingUTF-8-charsetUTF-web工程最后生成的是war .txt、源代 文 、warJSP我們要做是學(xué)生理系統(tǒng)班級表 [_目名 NUMBERnotnull,NAMEVARCHAR2(30),TEACHER學(xué)生表 NUMBERnotnull, BIRTHDAYDATE, altertableT_STUDENTaddconstraintPK_STUDENT_IDprimarykeyaltertableaddconstraintFK_STUDENT_CLASS_IDforeignkey(CLAID)referencesT_CLASS(ID)ondeletecascade;也可以根據(jù)條件加上checkaltertableaddconstraintCHECK_AGEcheck(age>0andage<100);altertableaddconstraintCHECK_check(genderin('男','女')); PK_表名(不要加T)_列1getset方【數(shù)據(jù)層】(2存放數(shù)據(jù)庫的操數(shù)據(jù)3存放數(shù)據(jù)庫的操456ServletWeb(表現(xiàn)層7servlet(UI指user89WEB-INF下。我們可以放在src或WEB-INF下,如果是src下,可以通過this.getClass().getClassLoader().getResourceAsStream()作了。切記不要再使用newFile的方式來了。 和com.guigu.service包中沒有文件,MyEclipse自作聰明把它合并了,這時候可以通過切換為什么要有com.guigu.exception如果我的sql語句寫錯SQLservice層知道出現(xiàn)異常了,所以我們不能在這里直接打印個堆棧,而是做出throwsSQLException有很大的弊 com.guigu.web.UI這個包里面的Servlet首先我們把要用到j(luò)avaBeanpackagecom.guigu.importimport項目名稱:guiguManager 類描述 創(chuàng)建人:吳長青Copyright(c) AllRightspublicclassCla{privateintid;privateStringname;privateStringprivateSet<Student>set=newid.獲得id屬性值的方法@returnthe JDKpublicintgetId()return}id為id賦值的方法 theidto JDKpublicvoidsetId(intid)this.id=}name.獲得name屬性值的方法@returnthe JDKpublicStringgetName()return}name為name賦值的方法 thenameto JDKpublicvoidsetName(Stringname)=}teacher.獲得teacher屬性值的方法@returnthe JDKpublicStringgetTeacher()return}teacher為teacher賦值的方法 theteacherto JDKpublicvoidsetTeacher(Stringteacher)this.teacher=}set.獲得set屬性值的方法@returnthe JDKpublicSet<Student>getSet()return}set為set賦值的方法 thesetto JDKpublicvoidsetSet(Set<Student>set)this.set=}publicCla()}publicCla(intid,Stringname,Stringteacher)this.id=id;=this.teacher=}/*(non-@seepublicStringtoString()return"Cla[id="+id+",name="+name+",teacher="+teacher+"]";}}packagecom.guigu.import項目名稱:guiguManager 創(chuàng)建人:吳長青Copyright(c) AllRightspublicclassStudent{privateintid;privateStringname;privateintage;privateStringgender;privateDatebirthday;privateClacla;id.id屬性值的方法@returnthe JDKpublicintgetId()return}idid賦值的方法 theidto JDKpublicvoidsetId(intid)this.id=}屬性值的方法@returnthe JDKpublicStringgetName()return}name thenameto JDKpublicvoidsetName(Stringname)=}age.age屬性值的方法@returnthe JDKpublicintgetAge()return}ageage賦值的方法 theageto JDKpublicvoidsetAge(intage)this.age=}gender.gender屬性值的方法@returnthe JDKpublicStringgetGender()return}gendergender賦值的方法 thegenderto JDKpublicvoidsetGender(Stringgender)this.gender=}birthday.獲得birthday屬性值的方法@returnthe JDKpublicDategetBirthday()return}birthday thebirthdayto JDKpublicvoidsetBirthday(Datebirthday)this.birthday=}cla.cla屬性值的方法@returnthe JDKpublicClagetCla()return}clacla賦值的方法 theclato JDKpublicvoidsetCla(Clacla)this.cla=}publicStudent()}publicStudent(intid,Stringname,intage,Stringgender,Datebirthday,Clacla){this.id=id;=name;this.age=age;this.gender=gender;this.birthday=birthday;this.cla=cla;}/*(non-@seepublicinthashCode(){finalintprime=31;intresult=1;result=prime*result+result=prime*result+((birthday==null)?0:result=prime*result+((cla==null)?0:cla.hashCode());result=prime*result+((gender==null)?0:result=prime*result+result=prime*result+((name==null)?0:return}/*(non-@seepublicbooleanequals(Objectobj)if(this==returntrue;if(obj==returnif(getClass()!=returnStudentother=(Student)if(age!=returnif(birthday==null)if(other.birthday!=null)returnfalse;}elseifreturnfalse;if(cla==null)if(other.cla!=null)returnfalse;}elseifreturnif(gender==null)if(other.gender!=null)returnfalse;}elseifreturnif(id!=returnfalse;if(name==null){if(!=null)returnfalse;}elseifreturnfalse;returntrue;}}packagecom.guigu.import項目名稱:guiguManager 類描述 創(chuàng)建人:吳長青Copyright(c) AllRightspublicclassPage{privateintbegin;privateintend;privateinttotalPages;privateinttotalRows;privateintcurrentPage=1;privateintpageRows=3;privateListlist;begin.獲得begin屬性值的方法@returnthe JDKpublicintgetBegin()returnpageRows*(current}begin為begin賦值的方法 thebeginto JDKpublicvoidsetBegin(intbegin)this.begin=}end.獲得end屬性值的方法@returnthe JDKpublicintgetEnd()return}end為end賦值的方 theendto JDKpublicvoidsetEnd(intend)this.end=}totalPages.獲得totalPages屬性值的方法@returnthe JDKpublicintgetTotalPages()return}totalPages為totalPages thetotalPagesto JDKpublicvoidsetTotalPages(inttotalPages)this.totalPages=}totalRows.獲得totalRows屬性值的方法@returnthe JDKpublicintgetTotalRows()return}totalRows為totalRows賦值的方法 thetotalRowsto JDKpublicvoidsetTotalRows(inttotalRows){this.totalRows=totalRows;this.totalPages=}currentPage.獲得currentPage屬性值的方法@returnthe JDKpublicintgetCurrentPage()return}currentPage為currentPage賦值的方 thecurrentPageto JDKpublicvoidsetCurrentPage(intcurrentPage)this.currentPage=totalPages;}elseif(current1<1){this.currentPage=1;this.currentPage=}}pageRows.獲得pageRows屬性值的方法@returnthe JDKpublicintgetPageRows()return}pageRows為pageRows賦值的方 thepageRowsto JDKpublicvoidsetPageRows(intpageRows)this.pageRows=}list.獲得list屬性值的方法@returnthe JDKpublicListgetList()return}list為list賦值的方 thelistto JDKpublicvoidsetList(Listlist)this.list=}}利用DBUtils來搭建DAOpackageimportjava.sql.Connection;importjava.sql.SQLException;importjava.util.List;項目名稱:guiguManager類全名 類描述 創(chuàng)建人:吳長青Copyright(c) AllRightspublicinterfaceICommonDao<T>*getForValue:(這里用一句話描述這個方法的作用TODO(這里描述這個方法適用條件–可選@author吳長青@param@param@param@throws@sinceJDKpublic<E>EgetForValue(Connectionconn,Stringsql,Object...args)throwsSQLException;getForList:(這里用一句話描述這個方法的作用TODO(這里描述這個方法適用條件–可選@author吳長青@param@param@param@throws@sinceJDKpublicList<T>getForList(Connectionconn,Stringsql,Object...args)throwsSQLException;update:(這里用一句話描述這個方法的作用TODO(這里描述這個方法適用條件–可選@author吳長青@param@param@param@throws@sinceJDKpublicvoidupdate(Connectionconn,Stringsql,Object...throwsget:(這里用一句話描述這個方法的作用TODO(這里描述這個方法適用條件–可選@author吳長青@param@param@param@throws@sinceJDKpublicTget(Connectionconn,Stringsql,Object...args)}packageimportimportjava.sql.Connection;importjava.sql.SQLException;importjava.util.List; 項目名稱:guiguManager類全名 創(chuàng)建人:吳長青Copyright(c) AllRights@parampublicclassCommonDaoImpl<T>implementsICommonDao<T>privateQueryRunnerqueryRunner=null;privateClass<T>clazz;publicqueryRunner=newQueryRunner();clazz=}/*(non- java.lang.String,java.lang.Object[])public<E>EgetForValue(Connectionconn,Stringsql,Object...throwsSQLExceptionreturnqueryRunner.query(conn,sql,new}/*(non- java.lang.String,java.lang.Object[])publicList<T>getForList(Connectionconn,Stringsql,Object...throwsSQLExceptionreturnqueryRunner.query(conn,sql,new}/*(non- java.lang.String,java.lang.Object[])publicvoidupdate(Connectionconn,Stringsql,Object...args)SQLExceptionqueryRunner.update(conn,sql,}/*(non- java.lang.String,java.lang.Object[])publicTget(Connectionconn,Stringsql,Object...args)SQLExceptionreturnqueryRunner.query(conn,sql,new}}packagecom.guigu.dao;importjava.util.List;importcom.guigu..Cla;項目名稱:guiguManager 類描述 創(chuàng)建人:吳長青Copyright(c) AllRightspublicinterfaceIClaDaoextendspublicvoidadd(Clapublicvoidupdate(Clapublicvoiddelete(intid);publicClafind(intid);publicList<Cla>getAll();publicintpublicList<Cla>getByPage(intbegin,int}packageimportjava.sql.Connection;importjava.sql.SQLException;importjava.util.List;importcom.guigu.dao.IClaDao;importcom.guigu..Cla;importcom.guigu.util.JdbcUtil;項目名稱:guiguManager類全名 創(chuàng)建人:吳長青Copyright(c) AllRightspublicclassClaDaoImplextendsCommonDaoImpl<Cla>implementsIClaDao/*(non-publicvoidadd(Clacla){Connectionconn=null;try{conn=Stringsql="insertintot_ClavaluesObject[]args={cla.getId(),cla.getName(),cla.getTeacher()};update(conn,sql,args);}catch(SQLExceptione){}}/*(non-publicvoidupdate(Clacla){Connectionconn=null;try{conn=Stringsql="updatet_Clasetname=?,teacher=?where=
Object[]args={cla.getName(),cla.getTeacher(),cla.getId()};update(conn,sql,args);}catch(SQLExceptione){}}/*(non-@seepublicvoiddelete(intid){Connectionconn=null;try{conn=Stringsql="deletet_Clawhereid=?";Object[]args={id};update(conn,sql,}catch(SQLExceptione){}}/*(non-@seepublicList<Cla>getAll()Stringsql="select*fromt_Cla";Connectionconn=null;List<Cla>list=null;try{conn=JdbcUtil.getConnection();list=getForList(conn,sql);}catch(SQLExceptione){}return}/*(non-@seepublicClafind(intid){Connectionconn=null;Clacla=null;tryconn=Stringsql="select*fromt_Clawhereid=?";cla=get(conn,sql,id);}catch(SQLExceptione){}return}/*(non-@seepublicintgetTotalRows(){Connectionconn=null;intcount=0;tryconn=Stringsql="selectcount(*)fromt_cla";count=getForValue(conn,sql);}catch(SQLExceptione){}return}/*(non-publicList<Cla>getByPage(intbegin,intend){Connectionconn=null;List<Cla>list=null;try{conn=Stringsql="select*from(selectc.*,rownumrnfrom*fromt_cla)whererownum<?)wherern>?";Object[]args={end,begin};list=getForList(conn,sql,}catch(SQLExceptione){}return}}packageimportimport import 項目名稱:guiguManager類全名 類描述 創(chuàng)建人:吳長青Copyright(c) AllRightspublicinterfaceIClaServicepublicvoidaddCla(Clacla);publicvoidupdateCla(Clac);publicvoiddeleteCla(intid);ClafindCla(intList<Cla>}PagegetByPage(Stringpackageimportimportimportimport import import項目名稱:guiguManager類全名 類描述 創(chuàng)建人:吳長青Copyright(c) AllRightspublicclassClaServiceImplimplementsprivateIClaDaoclaDao=new/*(non-publicvoidaddCla(Clacla){}/*(non-*@seepublicvoidupdateCla(Clac){}/*(non-*@seepublicvoiddeleteCla(intid){}/*(non-*@seepublicClafindCla(intid)return}/*(non-*@seepublicList<Cla>getAll()return}/*(non-*@seepublicPagegetByPage(StringcurrentPage){Pagepage=newPage();intcp=Integer.valueOf(currentPage);}List<Cla>list=claDao.getByPage(page.getBegin(),return}}packageimportimportimportimportimportimportimportcom.guigu.importcom.guigu.importimport項目名稱:guiguManager類全名 類描述 創(chuàng)建人:吳長青Copyright(c) AllRightspublicclassClaServletextendsHttpServletpublicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{Stringflag=request.getParameter("flag");IClaServicecla
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 配件買賣合同
- 湖北省十堰市2024-2025學(xué)年高二上學(xué)期1月期末地理試題 含解析
- 日常辦公事務(wù)處理文書詳案
- 融資借款合同協(xié)議書
- 數(shù)據(jù)傳輸效率評估表
- 產(chǎn)品分銷合同協(xié)議規(guī)范書
- 中學(xué)生科普知識解讀征文
- 電商平臺在線客服機(jī)器人技術(shù)支持協(xié)議
- 《現(xiàn)代酒店管理基礎(chǔ)》(第二版)課件 任務(wù)9 酒店集團(tuán)化管理
- 幼兒啟蒙成語故事解讀
- 2024年3、6、9月青少年軟件編程Python等級考試一級真題(全3套 含答案)
- 部編版小學(xué)語文三年級語文下冊第三單元集體備課教材分析解讀
- 2023年河北省安全生產(chǎn)舉報和獎勵答試題及答案
- 2021年中國遠(yuǎn)洋海運(yùn)集團(tuán)有限公司招聘筆試試題及答案解析
- 《大學(xué)物理學(xué)》課程教學(xué)大綱
- 勵志班會你想成為什么樣人
- ISOTS-9002:2022質(zhì)量管理體系ISO9001:2022-應(yīng)用指南
- 《帶狀皰疹治療學(xué)》牛德興教授專業(yè)研究治療病毒性皰疹50年心血
- 戴氏無線電遙控飛機(jī)教程
- 巴黎盧浮宮介紹PPT模板課件
- 蒂森克虜伯電梯曳引輪鋼絲繩安裝布置
評論
0/150
提交評論