zoukankan      html  css  js  c++  java
  • 2020/10/29

    一.在这里写几个关于dao的语句

    public boolean add(student s) {
            String sql = "insert into text3(sid,sname,ssex,sclass,szy) values('"+ s.getSid() + "','"+ s.getSname() + "','"+s.getSsex() + "','" + s.getSclass() + "','" + s.getSzy() +"')";
            Connection conn = DBUtil.getConn();
            Statement state = null;
            boolean f = false;
            int a = 1;
             
            try {
                state = conn.createStatement();
                state.executeUpdate(sql);
            } catch (Exception e) {
                e.printStackTrace();
                a=0;
            } finally {
                DBUtil.close(state, conn);
            }
             
            if (a > 0) {
                f = true;
            }
            return f;
    	}
    

     这是一个添加的sql的语句

    insert into text3(sid,sname,ssex,sclass,szy) values('"+ s.getSid() + "','"+ s.getSname() + "','"+s.getSsex() + "','" + s.getSclass() + "','" + s.getSzy() +"')";
    使用该条语句可以添加数据
     public boolean tsan(String x) {
        	
            String sql="delete from text2 where tname='"+x+"'";
            Connection conn = DBUtil.getConn();
            Statement state = null;
            boolean f = false;
            int a = 1;
             
            try {
                state = conn.createStatement();
                state.executeUpdate(sql);
            } catch (Exception e) {
                e.printStackTrace();
                a=0;
            } finally {
                DBUtil.close(state, conn);
            }
             
            if (a > 0) {
                f = true;
            }
            return f;
        }
    

     使用该条语句是可以删除数据,将要删除的东西传入函数就可将他一行的删去

    二.除了sql语句其他部分还不太了解

    三.web

  • 相关阅读:
    AES块加密与解密
    流加密的密文解密
    Linux命令——压缩和解压缩
    Linux之Vim学习
    Linux命令——磁盘管理
    Linux命令——用户和用户组管理
    Linux命令——文件和目录管理
    C++的技术探究
    Debian系统下实现通过wpa_config连接WPA-PSK加密的Wifi连接
    如何在openWRT系统上实现双版本
  • 原文地址:https://www.cnblogs.com/qiangini/p/14157416.html
Copyright © 2011-2022 走看看