安徽理工大学课程设计(论文)
else if(operate.equals(\安全退出\ System.out.println(\ System.out.println(\ System.out.println(\谢谢使用**********************************\ System.exit(0); } else{ System.out.println(\ System.out.println(\ System.out.println(\请您按要求正确输入:=============\ p = 0; } } } else{ System.out.println(\ System.out.println(\ System.out.println(\您的身份有问题!=============\ System.exit(0); } }catch(IOException i){ System.out.println(\键盘输入数据未能被正确读取!\ System.exit(-1); } } public static void query(){//此处定义了查询的方法 InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); try{ System.out.println(\ System.out.println(\ System.out.println(\查询界面=====================\ System.out.println(\ System.out.println(\ System.out.println(\姓名查询 2.论文名查询 3.科研成果名查询 \ System.out.println(\科研项目名查询 5.部门名查询 6.退出查询\ System.out.println(\ System.out.println(\ System.out.print(\请输入查询方式:\
-21-
安徽理工大学课程设计(论文)
String s = br.readLine(); while(s!=null){ if(s.equals(\姓名查询\ System.out.println(); System.out.println(); System.out.print(\请输入姓名:\ String name = br.readLine(); try{ //与数据库建立连接 Class.forName(\ String url=\ String user=\ String password=\ Connection conn= DriverManager.getConnection(url,user,password);//每用一次连接一次 PreparedStatement ps = conn.prepareStatement(\ distinct 职工号, 部门编号 from GeneralCourse where GeneralCourse.姓名=?\带参数的sql语句 ps.setString(1,name); ResultSet rs = ps.executeQuery(); String EmployeeId = null; String DId = null; while(rs.next()){ EmployeeId = rs.getString(1); DId = rs.getString(2); } if(EmployeeId!=null){ System.out.println(); System.out.println(); System.out.println(\姓名:\ 职工号:\ PreparedStatement ps1 = conn.prepareStatement(\职称,所在部门,文化程度 from Employee where 职工号=?\ ps1.setString(1,EmployeeId); ResultSet rs1 = ps1.executeQuery(); while(rs1.next()){ System.out.println(); System.out.println(); System.out.println(\职称:\所在部门:\文化程度:\
-22-
安徽理工大学课程设计(论文)
} PreparedStatement ps2 = conn.prepareStatement(\项目名称 from Item where Item.项目编号 in (select GeneralCourse.项目编号 from GeneralCourse where GeneralCourse.职工号=? )\TABLE); ps2.setString(1,EmployeeId); ResultSet rs2 = ps2.executeQuery(); int count1 = 0; while(rs2.next()){ count1++; } rs2.beforeFirst(); String[] Iname = new String[count1]; int i = 0; while(rs2.next()){ Iname[i] = rs2.getString(1); i++; } PreparedStatement ps3 = conn.prepareStatement(\成果名称 from Fruit where Fruit.成果编号 in (select GeneralCourse.科研成果编号 from GeneralCourse where 职工号 = ? ) \ ps3.setString(1,EmployeeId); ResultSet rs3 = ps3.executeQuery(); int count2 = 0; while(rs3.next()){ count2++; } rs3.beforeFirst(); String[] Fname = new String[count2]; i = 0; while(rs3.next()){ Fname[i] = rs3.getString(1); i++; } PreparedStatement ps4 = conn.prepareStatement(\论文名称 from Paper where Paper.论文编号 in (select GeneralCourse.论文编号 from GeneralCourse where 职工号 = ? )\TABLE);
-23-
安徽理工大学课程设计(论文)
ps4.setString(1,EmployeeId);
ResultSet rs4 = ps4.executeQuery(); int count3 = 0; while(rs4.next()){ count3++; } rs4.beforeFirst();
String[] Pname = new String[count3]; i = 0;
while(rs4.next()){ Pname[i] = rs4.getString(1); i++; }
System.out.println(); System.out.println();
System.out.println(\此人共发表论文数为:\ if(count3!=0){ System.out.print(\论文名如下:\ for(i=0;i System.out.println(); System.out.println(); System.out.println(\此人共做出科研成果数为:\ if(count2!=0){ System.out.print(\成果名如下:\ for(i=0;i System.out.println(); System.out.println(); System.out.println(\此人共接到科研项目数为:\ if(count1!=0){ System.out.print(\项目名如下:\ -24- 安徽理工大学课程设计(论文) for(i=0;i -25- }catch(Exception e1){ }