package come.hanqi.test;import java.sql.*;import java.util.Scanner;public class Shujuku { public static void main(String[] args) { Connection conn = null; try { Class.forName("oracle.jdbc.driver.OracleDriver"); String strUrl = "jdbc:oracle:thin:@localhost:1521:ORCL"; conn = DriverManager.getConnection(strUrl, "test", "wsjsk123"); Scanner sc = new Scanner(System.in); System.out.println("请输入考生的详细信息"); System.out.println("Type:"); int a = sc.nextInt(); System.out.println("IDCard:"); String b = sc.next(); System.out.println("ExamCard:"); String c = sc.next(); System.out.println("StudentName:"); String d = sc.next(); System.out.println("Location:"); String e = sc.next(); System.out.println("Grade:"); int f = sc.nextInt(); System.out.println("信息录入成功!"); Statement st = conn.createStatement(); st.executeUpdate("insert into examstudent values( se_test.nextval," + a + ",'" + b + "','" + c + "','" + d + "','" + e + "'," + f + ")"); ResultSet rs = st.executeQuery("select * from examstudent"); while (rs.next()) { int FlowID = rs.getInt(1); int Type = rs.getInt(2); String IDCard = rs.getString(3); String ExamCard = rs.getString(4); String StudentName = rs.getString(5); String Location = rs.getString(6); int Grade = rs.getInt(7); System.out.println("流水号:" + FlowID + " 四级/六级:" + Type + " 身份证号码:" + IDCard + " 准考证号码:" + ExamCard + " 学生姓名:" + StudentName + " 区域:" + Location + " 成绩:" + Grade); System.out.println("信息录入成功"); } rs.close(); st.close(); conn.close(); } catch (Exception e1) { e1.printStackTrace(); System.out.println("连接失败"); } }}
package come.hanqi.test;import java.sql.*;import java.util.*;public class Chaxun { public static void main(String[] args) { Connection conn = null; try { Class.forName("oracle.jdbc.driver.OracleDriver"); String strUrl = "jdbc:oracle:thin:@localhost:1521:ORCL"; conn = DriverManager.getConnection(strUrl, "test", "wsjsk123"); System.out.println("请选择您要输入的类型"); System.out.println("a:准考证号"); System.out.println("b:身份证号"); Scanner sc= new Scanner(System.in); String s = sc.next(); if(s.equals("a")) { System.out.println("请输入准考证号"); String zkz=sc.next(); Statement st = conn.createStatement(); ResultSet rs=st.executeQuery("select * from examstudent where ExamCard='"+ zkz+"'"); while(rs.next()) { System.out.println("流水号:"+ rs.getInt(1) + " 四级/六级:"+rs.getInt(2) + " 身份证号码:"+rs.getString(3)+ " 准考证号码:"+rs.getString(4)+ " 学生姓名:"+rs.getString(5)+ " 区域:"+rs.getString(6)+" 成绩:"+rs.getInt(7)); } } else if(s.equals("b")) { System.out.println("请输入身份证号"); String sfz=sc.next(); Statement st = conn.createStatement(); ResultSet rs=st.executeQuery("select * from examstudent where IDCard='"+ sfz+"'"); while(rs.next()) { System.out.println("流水号:"+ rs.getInt(1) + " 四级/六级:"+rs.getInt(2) + " 身份证号码:"+rs.getString(3)+ " 准考证号码:"+rs.getString(4)+ " 学生姓名:"+rs.getString(5)+ " 区域:"+rs.getString(6)+" 成绩:"+rs.getInt(7)); } } else { System.out.println("您输入有误!请重新进入程序"); } st.close(); rs.close(); } catch (Exception e1) { e1.printStackTrace(); System.out.println("连接失败"); } }}
package come.hanqi.test;import java.sql.*;import java.util.Scanner;public class Shanchu { public static void main(String[] args) { Connection conn = null; try { Class.forName("oracle.jdbc.driver.OracleDriver"); String strUrl = "jdbc:oracle:thin:@localhost:1521:ORCL"; conn = DriverManager.getConnection(strUrl, "test", "wsjsk123"); System.out.println("请输入学生考号"); Scanner sc=new Scanner(System.in); String s=sc.nextLine(); Statement st=conn.createStatement(); ResultSet rs=st.executeQuery("select * from examstudent"); String del="delete examstudent where examcard="+s; int j=st.executeUpdate(del); if(j>0) { System.out.println("删除成功!"); }else { System.out.println("查无此人!请重新进入程序..."); } } catch (Exception e1) { e1.printStackTrace(); System.out.println("连接失败"); } }}