欢迎来到天天文库
浏览记录
ID:47675612
大小:350.61 KB
页数:14页
时间:2019-10-19
《java程序实验报告mysql带有结果截图》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、TheFourthExperiment—Databaseprogramming▼3student▼冉Tables►IstuinfoQ1.InstallandconfigureAccess2013andMySQL5.6,createadatabasenamedstudentandadatatablenamedstuinfo,thecolumnsandtheirdatatypeshouldbethesameasthosetaughtintheclass,inputsomeinitialrecordsbyyourself.Fig1.1PKNNUQBUN
2、ZFAlGstuidVARCHAR(IO)stunameVARCHAR(45)mathDOUBLEenglishDOUBLEhistoryDOUBLEColumnNameDatatype□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□Fig1.2ResultGridstuidstunamemathenglishhistory2010186maryjackson20102989590mark201039692bambam20104761008420105tom707020106jenny946080
3、囲FilterRows:Fig1
4、3Q2.ConducttheCRUDoperationstothedatabaseanddatatablecreatedinQ1,thequeryoperationshouldincludewherecondition,whichshouldhastwoquerykeywordsatleast.Javacode;packagejava_mysql;importjava・sql・*;publicclassmysql_testl{publicstaticvoidmain(String[]args)throwsSQLException{Stringdb
5、url="jdbc:mysql://localhost:3306/student?"+HuseUnicode=true&characterEncoding=utf-8&useSSL=false”;Connectionconn=null;PreparedStatementstmt=null;ResultSetrs=null;intcount二0;Stringstuid_key="20102";doublemath_key=0;try{Class・/7or'/Va〃e("com.mysql・jdbt.Driver”);conn=DriverManag
6、er・getCo/?r)ec:t:io/7(dbur].,"roof”1234”);Stringsql="select*fromstuinfowherestuid>?andmath>?”+"orderbystuidasc";stmt二conn・prepareStatement(sql,ResultSet.T/PESCROLLINSENSITIVE,MM"ResultSet.CONCUR_READ_ONLY);stmt・setstring⑴stuid_key);stmt.setDouble(2jmath_key);rs=stmt・executeQu
7、ery();System.out.printIn("StuIDtH+"StuNameXt"+,,Mathtn+•'EnglishXt11+"History1');while(rs.next()){System.out.printIn(rs.getString(1)+"t"+rs・getString(2)+•At"+rs.getDouble(3)++rs.getDouble(4)+Htn+rs.getDouble(5));}System.out•printIn(””);rs・previous();count=rs.getRow();Syst
8、em.out.println(HThetotainumberofrecordsis"+count);}catch(SQLExceptione){System•out.println(e);}catch(ClassNotFoundExceptione){System.out.println("Thedriverhasnotbeenload");}finally{rs・close();stmt・close();conn・close();System.out.println(HPleasecloseconnectin’statementandresul
9、ter");}}}I码Snippets*ProblemsTasScreenshot:StuIDStuNameMathEnglis>hHi
此文档下载收益归作者所有