/***********************删除一个学生******************************/
public void DeleteStudent(String Sno) {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
con = JdbcUtils.getConnection();
try {
con.setAutoCommit(false);
String sql = "delete from student where sno=?";
pst = con.prepareStatement(sql);
pst.setString(1, Sno);
pst.executeUpdate();
String sql1="delete from user where users=?";
pst=con.prepareStatement(sql1);
pst.setString(1, Sno);
pst.executeUpdate();
con.commit();
}
<pre name="code" class="java"><strong><span style="font-size:32px;color:#ff0000;">删除一个学生的信息的同时 删除他的账号(两个表)</span></strong>