How can I use rollback() manually

Keywords: java mysql javafx

Question: 

So I am using JavaFX with mysql, and when I click a button, it executes an update and a delete. Another button should do a rollback. But when I click it, nothing happens on the db. Im using the setAutoCommit on the connection, and the commint when I click the first button. Any ideas?

connection.setAutoCommit(false);
boton1.setOnAction(evento -> {
                try {
                    PreparedStatement consultaA = conexion.prepareStatement(consulta2);
                    consultaA.setString(1, palabra);
                    consultaA.executeUpdate();
                    PreparedStatement consultaB = conexion.prepareStatement(consulta);
                    consultaB.setString(1, palabra);
                    consultaB.executeUpdate();
                    Statement consultaC = conexion.createStatement();
                    consultaC.executeUpdate(consulta3);
                    conexion.commit();
               } catch (SQLException ex) {
                    ex.printStackTrace();
                }

            });

 boton2.setOnAction(event -> {
                try {
                    conexion.rollback();
                } catch (SQLException ex) {
                    ex.printStackTrace();
                }
            });

Answers: