Tutorial :What is the right way to use JDBC transactions in Java?


I'm using this template:

try {      connection.setAutoCommit(false);        try {          // ... do something with that connection ...          connection.commit();      catch (SQLException exception) {          connection.rollback();          throw exception;      } finally {          connection.setAutoCommit(true);      }  } catch (SQLException exception) {      // log error  }  

Is this the right way? How can this template be improved?


Your code should work fine. Do you get any errors or anything else?

Here's an example on using JDBC Transaction anyway


P.S. Specify your problem and I'll try to help.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »