一.
今天在这里写了一个查找的函数
public List<information> tcha (String m) { String sql="select * from text2 where "; if(m!="") { sql+="tname = '"+m+"'"; } System.out.println(sql); Connection conn = DBUtil.getConn(); Statement state = null; ResultSet rs = null; List<information> list = new ArrayList<>(); try { state = conn.createStatement(); rs = state.executeQuery(sql); information bean = null; while (rs.next()) { String tid = rs.getString("tid"); String tname = rs.getString("tname"); String tsex = rs.getString("tsex"); String tlocation=rs.getString("tlocation"); String tzc = rs.getString("tzc"); System.out.println(tid); bean=new information(tid,tname,tsex,tlocation,tzc); list.add(bean); } } catch (Exception e) { e.printStackTrace(); } finally { DBUtil.close(state, conn); } return list; }
查找的函数和遍历相似
public List<jieyue> jiecha () { String sql="select * from jieyue"; Connection conn = DBUtil.getConn(); Statement state = null; ResultSet rs = null; List<jieyue> list = new ArrayList<>(); try { state = conn.createStatement(); rs = state.executeQuery(sql); jieyue bean = null; while (rs.next()) { String bid = rs.getString("bid"); String bname = rs.getString("bname"); String rid = rs.getString("rid"); String rname=rs.getString("rname"); String day = rs.getString("day"); bean=new jieyue(bid,bname,rid,rname,day); list.add(bean); } } catch (Exception e) { e.printStackTrace(); } finally { DBUtil.close(state, conn); } return list; }
这个函数是遍历
二.修改函数出现了一些意外
三.web