struts2根据主键更新某个列方法

  public boolean ChangeReturnStatus(String id,int nn){
          Connection conn=HibernateUtil.getSession().connection();
           String sql = "update TableName set a='" + nn+ "' where TypeID='"+id+"'";
             Statement stmt=null;
        int i=0;
        try {
            stmt=conn.createStatement();
             i= stmt.executeUpdate(sql);
           if(i!=0){
              return true;
           }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

你可能感兴趣的:(sql)