欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > DOCX文档下载  

    Java综合性试验-信息133-1232-张兴.docx

    • 资源ID:7179799       资源大小:298.74KB        全文页数:43页
    • 资源格式: DOCX        下载积分:5金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要5金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    Java综合性试验-信息133-1232-张兴.docx

    成果Java程序设计综合性试验学生成果管理系统学号201212030332姓名张兴班级信息133班试验步1 .数据库、数据表(或数据文件)设计<1)学生表信息设计CREATETAB1.E'studentinfo'('sno'int(20)NOTNU1.1.,sname-varchar(20)NOTNl'1.1.,sageint(10)defaultNU1.1.,ssexVtirchur(4)NOTNU1.1.,saddressvarchar(40)NOTNU1.1.,sclass-varchar(20)NOTNU1.1.,PRlMARYKEYCsno'),KEYsno('sno')运用uINSERTINTOstudentinfo-VA1.UESCsno,snamc,sage,ssex','saddress','sclass'):”语句将学生信息插入生成学生表:<2)课程表信息设计CREATETAB1.Ecourseinfo('cidint(10)NOTNU1.1.,'cname-varchar(20)defaultNU1.1.,cscoreint(5)defaultNU1.1.,'snoint(20)NOTNU1.1.,PRIRYKEYCcid')运用"INSERTINTOcourseinfoVA1.UESCcid','cnane,cscore,sno,);''语句将课程我信息插入生成课程表;2 .主控模块设计(1)主界面(2)录入学生成果信息(3)修改学生信息例如:将学号为“103”号的“王明”的年龄改为“19”,“班级”改为“会计2班”,将其高校英语课程的成果改为“89”;修改窗口:(4)增加学生信息增加一名学生信息,“109”,“林佳”,"19”,“女”,“理学院”,“信息1班”;录入窗口如图所示:录入后杳询如图所示:(5)删除学生信息将刚刚建立的“109号”“林佳''的信息删除:删除结果:4.学生信息杳询模块设计(1)按学生姓名查询(2)按学生学号查询(3)按学生所在班级隹询(4)按学生所在学院杳询5.课程信息自询模块设计(1)按“高校英语”课程查询:(2)按“高等数学”课程查询:通过综合试脸使我们学会了运用MyEclipsc,如何通过JDBC技术访问数据库,学会如何将数据表通过Java语句在MyEclipse中运用。同时还解广在Java中进行数据库应用程序开发的方法和步骤、SWing组件特性和ACIiOn接口以及如何开发多窗体应用程序。虽然这次试验的过程很艰难,但是最终和同学的探讨之后都克服,我信任这次试验对我们以后的学习肯定会有很大的帮助!username=prop.gctPropcrty("uscr">password=prop.gccPropcrty(*passwordM);)六*打开数据库连接tthrow$ClaSSNO(FOUlKlENCePIiOn/,动类找不到拿»lhrowsSQ1.Exccplion数据库连接出现问题*throwsNamingEXCCPtiQn/publicvoidgetConn()IhrOWSClaSSNoIFOUndEXCep<ion.SQ1.Exception.NamingExceptionClass.foName(StrDriver);conn=DrivcrManagcr.gctConncction(StrConncction.username,password>Contextcon=newlnitialConccx<();DataSourceds=(DauSource)con.lookuX"javaxom'envjdbc.,tesi3);conn=ds.gelConnccli>n():)京执行增、州、改刈语句。*ParamSql各种增、删、改语句。“rcturn受影响的行数.publicintUpdale(Stringsql)(inirsl=-I;try(gcConn();s(a(=conn.createStaien>e!H();rsl=Stat.CxeculeUpdatc(Sql):)catch(ClassNotFoundExccptionc)(c.prin(S(ackTracc();Icatch(SQ1.Exce<ione)e.priniStackTrace();)catch(NamingExccptionc)(c.princS(3ckTracc();)finallyIClOSCO:Jreturnrst;)"奉* 执行各种查询辆句.京用意:运用完毕后,要单独关闭数据摩资源* ParamSql查询语句* rcturn结果,/publicResuhSeiquerytS(ringsql)(try(gctConn():scat=conn.crcatcStatcmcn();r$=stat.execu(eQuery(sql):)catch(CIaSSN(F0undExccplione)(c.printStackTrace();Icatch(SQI.Exceptionc)e.ri11S(ackTrace();)catch(NaniingExceptione)e.printStackTracc();)re<urnrs;)public1.istqueryI(Siringsql,Classcls)1.istlis(=newArray1.iNO:try(gctConn();scat=conn.crcatcStatcn>en();rs=stat.execuieQuery(sql);wh!)e(rs.nex(O)(tryIObjectobj=cls.ncwlnstancc();FieldI!fields=ClsgeiDeciaivdFieIdsO;for(Fieldfield:fields)(Uy(Methodmethodcls.ge(DeclaredMethod(,se÷field.geNane().subs(ring(0.1).toU)erCase()+fiekl.ge(Nane,subs(ring(1>.field.gelType():methcxi.invokc(obj.ConvcrtUtils.convc11(rs.gctSring(fkld.gc(Namc(),ficld.gcT>,peO);Ca【ch(SecurityExceptione)(ITODOAuto-gcne11lcdcatchblockc.printStack,racc():cacch(IllcgalArgumcnlExccptionc)UTODOuto-genera(edcatchblocke.p11nlStackTracc();catch(NoSuchMeth(xiExccptionc)UTODOAuto-gcncratcdcatchblocke.xinStackTrace();catch(InvocationTargelExccptione>“TODOAuto-gcncratcdcatchblockc.printStackTracc();>list.add(obj);)catch<instanliationExccp(ionc)(e.rinStackTraceO:)catch<IllegalAccessExceplione)UprintStackTmceO;)catch(ClassNocFoundExceplione)(e.printStackTracc():Icatch(SQl.Exccpiionc)e.riuSackTrace();)catch(NaiiiingExcephone)(c.printStackTrace();JfinallyCIoSeaJreturnlist:1六*关闭数据库资源*/publicvoidclosc()tryif(rs!=null)rs.closc();)if(sial!=null)(stat.closc():)if(conn!=null)(COnn.close。;Jcatch(SQ1.Exccplionc)c.prinS(ackTracc():J)2 .设计表头信息packagecom.dao;publicclassJFmmCDac设置JTabIe的灰头publicSMngugeIDateTiIIecHStringtitle(=学号"."姓名二"年龄"."性别V地址","班级"):returntitle;IpublicString)OgetDateTide1()(Stringtittefl=(学号","姓名J年龄名性别V地址"."班级”,“课程二成果");returntitle;II3 .主页面代码packagecom.dao:imx>11java.sql.ResuhSei;on:ticy.StuBcan;publicclassStuDaoextendsDbDao显示全部学生信息publicString(showStu()throwsException(Stringa11=newStringge(Rows016J:intrw=0:Stringsq!=scl<xtfromStudcntlnlb*;RcsuhSclrs-supcr.qucry(sql);IryIwhi)e(rs.nexl<)(/Systcnwut.println(,rs中有数据”):将查到的记录放到二维数组中aw11O)=rs.ge(Im(I)÷mm:an>w)(1J=rs.getSlring(2);aDwJ(2=rs.gctJnt(3)+'*w;a11>w3=rs.getString(4);aIrow4)=rs.geS(ring(5);an>w)(5)=rs.gelSlring(6);保循环一次gw加1.并旦连到的记录添加到数组中row*÷catch(SQ1.Excep<ione)ODOAuto-gcncratcdcatchb!<kc.princScackTracc();)finally(super.closc():)returna;)添加学生信息publicintaddStu(intsno.Stringsnamc.intsagc.Stringsscx.Stringsaddrcss.Stringsclass)(Siringsqlwinserti11oStudentInfovalues(,M+sniH,V,+sname+*'VM+sage+''M+ssex+M,M+saddrcss+,',/,+sclass+Mr)M;inti=supcr.update(sql):returni;J/删除学生信刖publicintdclctcStu(intsnol)(Stringsql=dclccfromStudcntinfbwheresno-,w÷snol+”:inii=super.uxlate<sql);returni:)修改学生信息publicinichange(StingsnameJ11sage.S(ringssex.S(ringSaddN$,SIringsc!ass.i11sid)inii=0:Stringsql="updatcstudcntlnosetsnamc=,M+snamc+"sagc=<*+sage+K,.sscx=,*÷sscx+',saddrcss=÷saddrcss+*sclass=n'÷sclass÷,whereSnO="'+sid+"'二i=su)cr.upda(e(sql);returni:)显示学生成果publicSiringshowScore()throwsExceptionSiringa)11=newS<ring(gelRowsl()(8):introw=():SiringSqI=wSEI-ECTs.sno,snamc,sagc,sscx,saddrcssclass,cnamc,cscorcFROMSludeniintbs.courseinfocWHEREs.sno=c.sno,RcsuhSeln*=super.query(sql):try(whilc(rs.ncxt()(ntln("rs中有数据”):将更到的记录放到二维数祖中arow0)=rs.gct!nt(1)+mm;amw11l-rs.gc(S!ring(2);a(rowl21=rs.geiIn(3)+HW:an>w(3J=rs.getSlring(4):arow(4j=rs.gctString(5):amw5=rs.gccString(6);aIrow116)=rs.ge(String(7);aIn>w)7=rs.gelinU8)+mm;)returna;)publicSiring(showSlu3(StringXy)throwsException(Stringa(=ncwStringgciRows()J6:introw=0;Stringsql=selectfromSiudeiiUnfbwheresaddress=,M+xy+w,M;RcsuhSelrs=super.query(sql);Irylwhile(rs.xi()/Sys(em.ou(.println(Mrs中彳j数据”);将荏到的记录放到二堆数俎中a|n>wJ(OJ=rs.gctlnt(l)+MH;arowl-rs.gc(String(2);amw2j=rsgelm+Ta(rowJ3)=rs.getSlring(4);aIrow(4=rs.gctString(5):arow5=rs.gccString(6);常循环一次MW加1,并且一到的记录添加到数怨中row+:)IcatchISQ1.Exccpiionc)HTODOuio-genera(edcatchblockCpriniSlackTraceO:Jtinally(supcr.closc();)re<uma:JpublicString()JihowSIU4(Stringcourse)throwsExceptionStringa=newS(ringgeRows()8;intrw=0:Stringsq!=wSE1.ECTamc.cscorcER。MMudcniinfbs,courscinfocWHEREs.sno=c.snoandcnamc-,÷coursc÷*'"ResuhSetrs=super.query(sq!);lry(whilc(rs.ncxt()(Sys(cm.ou(.println("rs中有数据”);将杳到的记录放到:地数祖中an>w(O)=rs.gellnt(1)÷mm;aIrow1=rs.gctString(2):arow112=rs.gCHnt(3)+”;aIrow3=rs.ge(String(4);a(row(4j=rs.getSlring(5):a11>w(5j=rs.gctSt11ng(6):a11>w61=rs.gc<String(7);arow1171=rs.ge(I11(8)+,;修循环一次row加1.并且直到的记录添加到数姐中row+:catch(SQ1.EXCCP<ione)ODoAuto-gcncratcdcatchblockc.princScackTracc();)finally(super.closc();)Systcm.ou.prin!n(row);returna;)获得studentinfo表的记录条数publicintgctRows()throwsException!introw=0;Siringsql="selectcount(*)fromsilcnllnfo":RcsuItSctrs=super.qucry(sql):whilc(rs.ncxt()row=rs.gedn(l);)/Systcm.out.println(row);supcr.closc();returnrow:J获得studentinfo表的记录条数publicintgclRowsl()throwsExccpiionJintrow=0;Siringsql=sel<xtcunt(*)fromctnrscinf*:RcsuItSctrs=super.query(sql):whilc(rs.ncxt()w=rs.gedn(l):)/Systcm.out.println(rDw);super.closc();re<umrow:J/publicstaticvoidmain(String(args)throwsExceptionU/newStuDo().dclctcStu(22();UnewSluDaOo.addSu(2IOJ肖明19.”男“.“理学院".“信息2班)4 .学生信息类代码packagecom.entity;publicclassStuBean(privateintsid;privateintsno;privateStringsnane;privateintsage:privateStringSsCx:privateStringsaddrcss;privateStringsclass;publicinigelSid(>returnsid:IpublicvoidSelSid(inisid)lhis.sid=sid:IpublicintgcSno()returnsno;IpublicvoidSetSnO(intsno)(Chissno=sno;IpublicStringgelSnan>e<)returnsname;IpublicvoidsetSnane(Stringsname)lhis.sname=sname;IpublicintgcSagc()(returnsage;IpublicvoidsctSagc(intsage)this.sagc=sage;IpublicStringgclSscx()returnSsCx:IpublicvoidSetSSeX(SIringssex)this.sscx=ssex:publicStringgelSiMidrcssO(returnsaddress:publicvoidsctSaddrcss(StringSaddrCSS)(his.saddrcss三saddrcss;IpublicStringgclSclass()returnsclass:IpublicvoidseSclass(Siringsclass)(his.sclass=sdass:II5 .学生成果类代码tily;publicclassScorcBcanprivateintsno;privateStringsnane;privaieintsage:privateStringSSCx:privateStringsaddrcss;privateStringsclass;privaieStringcnane:privateintcscorc;publicintgcSno()returnsno;IpublicvoidSetSno(intsno)(his.sno=sno;IpublicStringgelSnan>d)returnsname;IpublicvoidSelSIIame(Slringsnane)(his.sname=sname:Ipublicin(getSagc()(returnsage;IpublicvoidsetSagclintsage)(his.sagc=sage;IpublicStringgelSscx()returnssex;IpublicvoidSetSseX(SIringssex)lhis.sscx=Ssex:publicStringgetSaddrcssOreturnSaddrepublicvoidsetSaddrcss(StringSaddrCSS)(his.saddrcss=saddrcss;IpublicStringgclSclass()returnsclass:IpublicvoidSelSdaSS(SIringsclass)(lhis.sclass=sclass;IpublicStringgctCnamc()(returncname;IpublicvoidsetCnamdStringcnamc)IhiSanc-cnamc;IpublicinigelCscorc()returncscore;IpublicvoidSeICSCoN(iinCSCore)(lhis.csjre=cscrc;II6 .增加功能的实现代码产AddlnfoJava*Createdon_DATE_TIME_WpackageCom.view:importjava.awt.TextField;imx>11javax,swing.JOpiionPane;importcm.dao.StuDao:tauthor_USER_publicclassAddlnfoextendsjavax.swingJFramc户"CreatesnewtbrnAddInfo*/publicAMnfoOInilComponentsO;this.sctr11tlc("4入窗口"):1*Thisn阳hodiscalledfx>nwithintheconstructorto*initializetheform. WARNING:DoNO,modifythiscode.Thecontentofthismethodis alwaysregeneratedbytheFormFuiitor. f/GEN-BEGIN:inIlConiponents/<cditor-fblddcfaultstatc=Mco!lapscd,'dcsc="GencratcdCodc,>>privatevoidinitComponcnts()jDialogl=newjavax.swingJDialogO;j1.abel1=newjavax.swingJ1.abcK):JIcxtFicldl=newjavax.swingJTcxtFicld():j4ibc!2二newjavax.swingJI.abcl();jTex<Field2=newjavax.swingJTextFieldO;jlex(Ficld3=newjavax.swingJTextFieIdO:j,extb'icld4=newjavax.swingJTcxtFicIdO;JlcxtFicldS-newjavax.swingJTextFicIdO;j1.abel3=newjavax.swingJ1.abel();j1.abel4=newjavax.swingJ1.abe)():j1.abc!5=newjavax.swingJ1.abcl():jButtonl=newjavax.swingJBuon();jBuon2=newjavax.swingJBuuon();j1.abel6=newjavax.swingJ1.abc)():jlextEic!d6=newjavax.swingJTcxtFicld():javax.swing.Groupl4iyoutjDialogI1.ayom=newjavax.swing.Group1.ayou(jDialog1.ge(CoineniPaneO);jDialog1.gelContenlPanc().se<1.ayout(jDialog!1.ayout):jDialogl1.ayout.sciHorzontalGroup(jDialogl1.ayout.createParallclGroup(javax.swing.Group1.ayout.Alignmcnt1.EADING).addGap(0,400ShoirMzXX-VA1.UE);jDialog11.ayou1.selVerticalGroup(jDialogI1.ayul.crealePa11lklGroup(javax.swing.Groupl-ayout.Alignncnt.1.EADING).addGap(0.300.Short.MAX.VA1.UE);se(DefauhCloseOpenition(javax,swing.Win<lowCons(ants.EXiT_ON_C1.OSE);j1.abel1.setFoH(newjaaaw1.Fon("微软德黑.0.18»j1.abel1.setcxt(,u59d3,.u54()d):jIwbcl2.scFom(ncwjaaawi.Fom(“微软雅圾二0,18»j1.abel2.se(lx(,u5e74u9ra4,);j1.abel3.SCIFOtn(newjaaawtFom("微软轴黑,0.18):j1.abcl3.sctTcxt(,u6()27u522b):jl二IhCI4.sclFom(ncwjaaawl.Fon("微软雅黑二0,18»j1.abel4.se(Tex("u73edu7ea7w);j1.abMS.sclFonUncwjuau<,Fom("微软雅黑二0.18»j1.abcl5.sdTcxt(u5b66u9662,);jButonl.sc(Tcx(Mu786c5b9a,);jBuon1.addMoUSe1.iSienertnewjava.awi.evem.MouseAdap<er()publicvoidrnouseClicked<java.awi.event.MouseEventevt)(jButtonIMouscCiickcd(CVt);)J):jBullon2.sc11x心uS3d6R6d88):jButton2.addMousc1.istcner(ncwjava.awt.cvcnt.MouscAdap<cr()(publicvoidmuscClickcd<java.awt.cvcnt.MouscEvcntCVl)(jBton2MouseClicked(evt););j1.bcl6JiClFOm(ncwjaaaw.Fom("徵状雅累二O,18»j1.abel6.$eiTeW”u5b66R53fn:javax.swing.Group1.ayulIayoul=newjavax.swing.Group1.ayiMil(gctContcntPanc();gc<CntcntPanc().sct1.ayout(layout);la>,out.se(Horizonta!Group(layout.crenteParallelGroup(javax.swing.Gr)up1.iout.AHgnnwnt.1.EADiNG).addGroup<layout.crcalcScqucntialGroup().addGap(28.2&28).addGroup(layout.crcatcParallclGrr>up(javax.swing.Gfoup1.ayoui.Alignment.1.E?DING).ad<IGrup<layout.crcatcScqucntialGroup().addConponen(j1.abel2).addGap(18.18.8).a<ldComponeni(jTcxtField2.javax.swing.Group1.ayout.DEFAU1.T.SIZE.122.Sho11.MAX-VA-UE),addGroXlayout.crcatcScqucntialGroup().idComponcnt(j1.abel3).addGap(18.18.18).addComponcH(jTex(Field3.javax.swing.Groupl.ayout.DEFAUI.T_SIZE.22.Short.MAX-VA1.UE).a(kiGroup<IayoutxrealcSequcntialGnMip<>.addPrccrrcdGap(javiix.swing.1.ayou(Stylepone11Pkcement.RE1.ATED).addCmponcnl(j1.abcl4).addGap(18,18,18).addCmp<)ncnl(jTcxtFicld4.javax.swtng.Group1.ayoutDEFAU1.TjSlZE,122,Shor(AIAX-VA1.UE).addGroup<layut.crcatcScqucntialGro<p().a<ldPefe11dGap(javax.swing.1.ayoutStylepwcntPlaccmcnt.RE1.AED).a<ldGroup(IayoutxreateParaIlelGn>up<javax.swing.Groupl.ayoutAlignment.I.EADING).addG11>up(jBuon2).addGap<25.25,25).addGroup<layout.createSequen(ialGrouX).addG11)up(Iayou1.crcitcParaIlclG11>up(javax.swing.Grup1.ayout.Align11cnl.1.EADING).addComponcnt(j1.abell.javax.swing.Group1.ayom.PREFERRED_SlZE,50.javax.suing.Groupl.ayout.PREFERRED_SIZE).addComponent(jlbe16).addGa(5.5.5).iiddGrx>up(IayautxrcatcParaIlclGroup(javax.swing.Gro<ip1.ayout.AIignmenta1.EADING).addComponcnt(jlextField6.javax.swing.Group1.ayou(.DEFAUl.T_SIZE,Short.MAX_VAI.UE).addComponcnl(jTx(FicW1.java.swing.Group1.ayut.PREFERRED-SlZE.2l,javax.swing.Group1.ayul.PREERRED-SIZE)>.addContaincrCiap(65.Sbort.MAX.VA1.UE);layout.sc(rticalGroup(layout,createParallelGtup(javax.swing.G!up1.ayol.Alignnwnt.1.EADING).addGroup<IayoutxrcatescqucntiaIGroupC).addGap(25,25,25).addGroup(layout.creatcParallelGn>up(javax.swing.Gr<wpI.ayout.Alignmcn.1.EADING,false).addCornponenUjTexlFicld6).addCononcnt(j1.abc16,javax.swing.Group1.ayout.DEFAU1.T_SIZE.javax.swing.Group1.ayou.DEEMJ1.T.SIZE.Sho11.MX.VA1.UE).addPrcfeedGapjavax.swing.1.ayoutStylcpnc11(Placcmcnt.REI.ATED).addGroup(layout.createParallelG11>up(javax.swing.GroupI.ayout.Alignmcn.BASEI.iNE)二UMCOmPonenNj1.abell.javax.swing.Groupl.ayout.PREFERRED-SIZE,javax.swing.Group1.ayout.PREEERRED_SlZli).addCmponcnt(jlx(Field1.javax.swing.Group1.ayout.PREHiRRED_SlZE.26,javax.swing.Grup1.ayout.PREFERRED-SIZE).addPrcfccdGap(javax.swing.IUiyoutStyIcPoneiHPIacement.RE1.ATED).addG11)up(layout.creatcParallclGroup(javax.swing.Group1.ayout.Alignment.BASE1.INE).a<klCo11

    注意事项

    本文(Java综合性试验-信息133-1232-张兴.docx)为本站会员(李司机)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开