I have a application that updates several table at 1 time. But now i want to make sure that any failure in updating any 1 of the tables, the database would rollback to the original state. How should i design the structure of my application?

JSP page --- >> Servlet --- >> Controller --- >> Database

In my jsp page, this is where the user enters the data and submit. The servlet would capture all the data that the user enter into the textfield. The Controller class is a file, which i code to manage the updating of the records and also responsible for calling other classes to update to the database. For the database class it is just a class i coded to connect to database, and accept SQL statements through a method to perform insert,update,delete,query.

In my controller, i would call Class A and B to perform update operations.

so in Class A and B i would have something that look like this

Code:
public class A
....
public void updateRecord()
{
    String sql = // here goes my sql update statement...
    Database db = new Database();
    db.executeUpdate(sql);
}
in my database class
Code:
public class Database
....
public void executeUpdate(String sql)
{
    // all the update to database goes here
}
in my controller class
Code:
public class UpdateController()
{
   A a = new A();
   a.updateRecord();
  
   B b = new B();
   b.updateRecord();
}
where should i insert the codes to ensure the updating of the records smoothly?