一.在这里写几个关于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