jsp数据库事务
回滚操作
<%
Connection conn=null;
try{
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/test",
"root","123456");
Statement stat=conn.createStatement();
conn.setAutoCommit(false);
String sql1="insert into student(name,id) values('djf','0004')";
String sql2="insert into student1(name,id) values('djf','0004')";
conn.commit();
}catch(Exception ex){
conn.rollback();
}finally{
conn.close();
}
%>