Cannot access SqlTransaction object to rollback in catch block

using (var Conn = new SqlConnection(_ConnectionString)) { SqlTransaction trans = null; try { Conn.Open(); trans = Conn.BeginTransaction(); using (SqlCommand Com = new SqlCommand(ComText, Conn, trans)) { /* DB work */ } trans.Commit(); } catch (Exception Ex) { if (trans != null) trans.Rollback(); return -1; } } or you could go even cleaner and easier and … Read more

EJB3 transaction rollback

First of all, there is no rollback of an exception, it’s a rollback of a transaction. If you throw your exception with @ApplicationException(rollback=true), you don’t have to rollback the transaction manually. Context.setRollbackOnly() forces the container to rollback the transaction, also if there is no exception. A checked exception itself doesn’t rollback a transaction. It needs … Read more

Rails: Is it bad to have an irreversible migration?

If you are dealing with production-grade systems then yes, it is very bad. If it is your own pet project, then anything is allowed (if nothing else, it will be a learning experience 🙂 though chances are that sooner rather than later, even in a pet project, you will find yourself having put a cross … Read more

mysql transaction – roll back on any exception

You can use 13.6.7.2. DECLARE … HANDLER Syntax in the following way: DELIMITER $$ CREATE PROCEDURE `sp_fail`() BEGIN DECLARE `_rollback` BOOL DEFAULT 0; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET `_rollback` = 1; START TRANSACTION; INSERT INTO `tablea` (`date`) VALUES (NOW()); INSERT INTO `tableb` (`date`) VALUES (NOW()); INSERT INTO `tablec` (`date`) VALUES (NOW()); — FAIL IF … Read more

What is the difference between rollback, backout and strip in the Mercurial Eclipse plugin?

These commands all come from Mercurial itself, and there are plenty of good compare/contrast posts for them. However, here they are in brief: rollback: one-level undo. Will undo the last pull or commit (can be dangerous) backout: create a new commit that is the inverse of a given commit. Net effect is an undo, but … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)