rollback()
Connection conn = …… //省略部分程式碼 conn.setAutoCommit(false); //先將事務設為手動提交 Statement st = conn.createStatement(); String sql = "DELETE FROM users WHERE username='xiaoli'"; st.execute(sql); conn.roolback(); //將事務回滾
rollback(Savepoint savepoint)
引數說明:Connection conn = …… //省略部分程式碼 conn.setAutoCommit(false); //先將事務設為手動提交 Statement st = conn.createStatement(); String sql = "DELETE FROM users WHERE username='xiaoli'"; st.execute(sql); conn.roolback(spName); //將事務回滾到儲存點