jdbc 删除数据练习
发布日期:2021-08-13 19:50:51 浏览次数:7 分类:技术文章

本文共 1993 字,大约阅读时间需要 6 分钟。

public static void main(String[] args) {        Scanner sc = new Scanner(System.in);        System.out.println("请选择您要输入的类型:");        System.out.println(" " + "a:身份证号");        System.out.println(" " + "b:准考证号");        String s = sc.next();        Connection conn = null;        try        {            Class.forName("oracle.jdbc.OracleDriver");            String url = "jdbc:oracle:thin:@localhost:1521:ORCL";            conn = DriverManager.getConnection(url, "test1", "574004");            System.out.println("连接数据库成功");            Statement st = conn.createStatement();            if (s.equals("a"))             {                                    System.out.println("请输入身份证号:");                    String ID = sc.next();                    String IDCard = "select * from EXAMSTUDENT t where idcard=" + ID;                    ResultSet rs = st.executeQuery(IDCard);                    if (ID != "select idcard from EXAMSTUDENT t ")                    {                        System.out.println("您输入有误,请重新进入程序......");                        }                    while (rs.next())                     {                        String fl = rs.getString(1);                        String ty = rs.getString(2);                        String id = rs.getString(3);                        String ex = rs.getString(4);                        String stu = rs.getString(5);                        String lo = rs.getString(6);                        String ga = rs.getString(7);                        System.out.println("flowid=" + fl + ",type=" + ty + ",idcard=" + id + ",examcard=" + ex + ",姓名:"                                + stu + ",籍贯:" + lo + ",分数:" + ga);                    }                                                System.out.println("请输入学生的考号:");                String id = sc.next();                st.execute("delete  from examstudent t where t.examcard =  "+id);                                System.out.println("删除成功");

转载于:https://www.cnblogs.com/zhailiming/p/5606168.html

转载地址:https://blog.csdn.net/weixin_30699235/article/details/99159930 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:学习总结
下一篇:WEB 前端插件整理

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2024年04月15日 19时46分02秒