zoukankan      html  css  js  c++  java
  • 每日日报2020 11/21

    今天我写了Dao层。

    public boolean add(User user) {
    String sql = "insert into student(id,name,aclass,kecheng,score)"
    + "values('" + user.getId() + "','" + user.getName()+ "','" + user.getAclass() + "','" + user.getKecheng()+ "','" + user.getScore()+ "')";
    Connection conn = DBUtil.getConn();//调用方法连接数据库
    Statement state = null;//创建一个Statement对象来执行静态的SQL语句
    //Statement用于在已经建立数据库连接上发送静态的SQL语句
    boolean f = false;
    int a = 0 ;

    try { //监视大括号内的代码
    state = conn.createStatement();//上面的是详解
    a = state.executeUpdate(sql);
    //执行指定的更新类的SQl语句,并返回操作结果的整型值
    } catch (Exception e) { //捕获错误
    e.printStackTrace();
    } finally {
    //关闭z 连接
    DBUtil.close(state, conn);
    }

    if (a > 0) {
    f = true;
    }
    return f;
    }

  • 相关阅读:
    Qt 去除控件边框线
    Qt 自定义可编辑 模型视图
    Qt double类型输出问题
    vue实例
    初识vue
    python中的数据类型
    python 列表解析式
    Goland常用快键键 mac pro
    文档对象模型DOM
    正则表达式
  • 原文地址:https://www.cnblogs.com/song-1/p/14177013.html
Copyright © 2011-2022 走看看