package test_1; import java.sql.*; import java.util.Scanner; public class lianxi3 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("请输入您要删除的准考证号"); String z=sc.next(); Connection con=null; try { Class.forName("oracle.jdbc.driver.OracleDriver"); String struil="jdbc:oracle:thin:@localhost:1521:ORCLER"; con=DriverManager.getConnection(struil, "test", "asd123"); System.out.println("连接数据库成功"); Statement st= con.createStatement(); int i=st.executeUpdate("delete examstudent where examcard="+z); if(i>0) { System.out.println("删除成功!"); } else { System.out.println("查无此人,请重新输入........."); } } catch(Exception e) { e.printStackTrace(); System.out.println("连接数据库失败"); } } }